Created
November 30, 2019 19:43
-
-
Save phattv/a1cbe9400258bc6f1d0faf06a8d95c0a to your computer and use it in GitHub Desktop.
Revisions
-
phattv created this gist
Nov 30, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ # Setup Google Cloud Platform (GCP) - 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 # Build and deploy Docker image - 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` or `docker 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 account - `docker -- push {image_name}` # Apply Docker image on vm instance without Kubenetes (k8s) - ssh with external IP - `docker images` - `docker run --name {container_name} --rm -d -p 80:80 {image_name}` # Apply Docker image on vm instance with Kubenetes (k8s) - TODO: https://github.com/phattv/sp-evisa/blob/master/k8s/kubenetes.md ### Tips and tricks - Copy from local terminal to remote shell: ``` vim file :set paste cmd + v :wq ``` or ``` cat >file cmd + v ctrl + d ```