Source Imgur
We might want to quickly deploy our code to make sure it works or just want to have a server to play around with for free.
Certainly, you can!
As a student, I wanted to know and use services for free and forever. Thats the background of this post and the previous post (go check if you haven't read it)
But how do we get that?
Google Cloud provides us to use free tier compute engine.
Without further, let's go!
First time know about this, I certainly say "this is for me".
Setup Server
Go to GCP then signup/in.
If you are new, you can get $300 credit by use free trial (click on 'Get started for free' or here)
Go to Compute Engine
Enable Compute Engine API here if not enabled
Setup billing, need a credit card but dont worry you won't get charged.
Create VM, instance
Make sure you create in free tier locations (
us-west1
,us-central
,us-east1
) with machine typee2-micro
andstandard persistent disk
up to 30GB, as stated here.Also, make sure allow HTTP and HTTPS.
Connect via SSH
Thats it.
Testing
Let's quickly try our new server by creating an express app.
Install dependencies
Connect via SSH
Update package Linux
sudo apt update
Install Node.js
sudo apt install nodejs
Check with:
node -v
Output:
v8.10.0Install NPM
sudo apt install npm
Create Express
Quick start create express app here
Install executable
npm install -g express-generator@4
Create app
express /tmp/foo && cd /tmp/foo
Install dependencies
npm install
Start server
Before we start, we have to change port server
3000
to80
.sudo pico bin/www
Search for
3000
or go to line (CTRL + SHIFT + _) 15 and change into80
.Exit (CTRL + X).
Run server
sudo npm start
See public
Navigate to Compute Engine and click external IP.
You'll find something like this:
P.S. This is for testing only, make sure to correct deploy your app.
Next Step
Deploy project on the server and play around with.
NOTE: The server running for free, but Google might charge if you are over the free usage limit. Also, Google may change their terms for "forever" (read: Google Photos)
IMPORTANT: You may be charged because of Network Egress to China and Australia.
Reach Me
Any issue? Reach me at [email protected]