- Login to https://console.cloud.google.com/
- Create a project (take note of project's ID)
- Enable billing
- Go to https://console.cloud.google.com/compute/instances
- Create a VM instance
- Name: use a semantic name (take note of instance's name)
- Region and zone: most local
- Machine type: smallest possible f1-micro
- (Optional) Tick "Deploy a container image to this VM instance" and enter the Docker image name
- Boot disk: Choose Debian/Linux or Container-Optimized OS
- Create & wait (take note of instance's external IP)
- Go to https://console.cloud.google.com/compute/metadata/sshKeys
- Add local ~/.ssh/id_rsa.pub content for project-wide ssh access
- Make sure ssh with external IP works
- Enable project's Container Registry API
- Add Dockerfile
docker build . -t {image_name}
(gcr.io/{project_id}/{instance_name}:{image_tag}) (e.g.gcr.io/phattv-ecommerce/phattv-ecommerce-backend:1.0.0
ordocker build . -t gcr.io/evisa-198403/evisa:3.1.1
)- (optional)
docker run --name {container_name} --rm -d -p 80:80 {image_name}
gcloud auth login
& choose your accountdocker -- push {image_name}
- ssh with external IP
docker images
docker run --name {container_name} --rm -d -p 80:80 {image_name}
- Copy from local terminal to remote shell:
vim file
:set paste
cmd + v
:wq
or
cat >file
cmd + v
ctrl + d