{"id":15789517,"url":"https://github.com/jeffdecola/hello-go-deploy-gce","last_synced_at":"2026-02-19T07:01:29.590Z","repository":{"id":55877438,"uuid":"174427686","full_name":"JeffDeCola/hello-go-deploy-gce","owner":"JeffDeCola","description":"Test, build, push (to DockerHub) and deploy a long running \"hello-world\" Docker Image to Google Compute Engine (gce).","archived":false,"fork":false,"pushed_at":"2025-04-20T18:58:09.000Z","size":2469,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-04T19:06:11.568Z","etag":null,"topics":["concourse","docker","dockerhub","dockerimage","gce","gcp","go","golang","google","google-cloud-platform","google-compute-engine","packer"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JeffDeCola.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-03-07T22:09:34.000Z","updated_at":"2025-04-20T18:58:13.000Z","dependencies_parsed_at":"2024-10-26T03:25:50.323Z","dependency_job_id":"2db963fa-3620-4ad5-b8ea-23acda52b2a8","html_url":"https://github.com/JeffDeCola/hello-go-deploy-gce","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/JeffDeCola/hello-go-deploy-gce","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JeffDeCola%2Fhello-go-deploy-gce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JeffDeCola%2Fhello-go-deploy-gce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JeffDeCola%2Fhello-go-deploy-gce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JeffDeCola%2Fhello-go-deploy-gce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JeffDeCola","download_url":"https://codeload.github.com/JeffDeCola/hello-go-deploy-gce/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JeffDeCola%2Fhello-go-deploy-gce/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29605798,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T06:47:36.664Z","status":"ssl_error","status_checked_at":"2026-02-19T06:45:47.551Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concourse","docker","dockerhub","dockerimage","gce","gcp","go","golang","google","google-cloud-platform","google-compute-engine","packer"],"created_at":"2024-10-04T22:02:03.394Z","updated_at":"2026-02-19T07:01:29.574Z","avatar_url":"https://github.com/JeffDeCola.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HELLO GO DEPLOY GCE\n\n[![Tag Latest](https://img.shields.io/github/v/tag/jeffdecola/hello-go-deploy-gce)](https://github.com/JeffDeCola/hello-go-deploy-gce/tags)\n[![jeffdecola.com](https://img.shields.io/badge/website-jeffdecola.com-blue)](https://jeffdecola.com)\n[![MIT License](https://img.shields.io/:license-mit-blue.svg)](https://jeffdecola.mit-license.org)\n[![Go Reference](https://pkg.go.dev/badge/github.com/JeffDeCola/hello-go-deploy-gce.svg)](https://pkg.go.dev/github.com/JeffDeCola/hello-go-deploy-gce)\n[![Go Report Card](https://goreportcard.com/badge/github.com/JeffDeCola/hello-go-deploy-gce)](https://goreportcard.com/report/github.com/JeffDeCola/hello-go-deploy-gce)\n[![Docker Pulls](https://badgen.net/docker/pulls/jeffdecola/hello-go-deploy-gce?icon=docker\u0026label=pulls)](https://hub.docker.com/r/jeffdecola/hello-go-deploy-gce/)\n\n_Deploy a \"hello-world\" docker image to\nGoogle Compute Engine (gce)._\n\nOther Services\n\n* PaaS\n  * [hello-go-deploy-aws-elastic-beanstalk](https://github.com/JeffDeCola/hello-go-deploy-aws-elastic-beanstalk)\n  * [hello-go-deploy-azure-app-service](https://github.com/JeffDeCola/hello-go-deploy-azure-app-service)\n  * [hello-go-deploy-gae](https://github.com/JeffDeCola/hello-go-deploy-gae)\n  * [hello-go-deploy-marathon](https://github.com/JeffDeCola/hello-go-deploy-marathon)\n* CaaS\n  * [hello-go-deploy-amazon-ecs](https://github.com/JeffDeCola/hello-go-deploy-amazon-ecs)\n  * [hello-go-deploy-amazon-eks](https://github.com/JeffDeCola/hello-go-deploy-amazon-eks)\n  * [hello-go-deploy-aks](https://github.com/JeffDeCola/hello-go-deploy-aks)\n  * [hello-go-deploy-gke](https://github.com/JeffDeCola/hello-go-deploy-gke)\n* IaaS\n  * [hello-go-deploy-amazon-ec2](https://github.com/JeffDeCola/hello-go-deploy-amazon-ec2)\n  * [hello-go-deploy-azure-vm](https://github.com/JeffDeCola/hello-go-deploy-azure-vm)\n  * [hello-go-deploy-gce](https://github.com/JeffDeCola/hello-go-deploy-gce)\n    **(You are here)**\n\nTable of Contents\n\n* [OVERVIEW](https://github.com/JeffDeCola/hello-go-deploy-gce#overview)\n* [PREREQUISITES](https://github.com/JeffDeCola/hello-go-deploy-gce#prerequisites)\n* [SOFTWARE STACK](https://github.com/JeffDeCola/hello-go-deploy-gce#software-stack)\n* [RUN](https://github.com/JeffDeCola/hello-go-deploy-gce#run)\n* [STEP 1 - TEST](https://github.com/JeffDeCola/hello-go-deploy-gce#step-1---test)\n* [STEP 2 - BUILD (DOCKER IMAGE VIA DOCKERFILE)](https://github.com/JeffDeCola/hello-go-deploy-gce#step-2---build-docker-image-via-dockerfile)\n* [STEP 3 - PUSH (TO DOCKERHUB)](https://github.com/JeffDeCola/hello-go-deploy-gce#step-3---push-to-dockerhub)\n* [STEP 4 - DEPLOY (TO GCE)](https://github.com/JeffDeCola/hello-go-deploy-gce#step-4---deploy-to-gce)\n  * [STEP 4.1 BUILD A CUSTOM MACHINE IMAGE USING PACKER](https://github.com/JeffDeCola/hello-go-deploy-gce#step-41-build-a-custom-machine-image-using-packer)\n  * [STEP 4.2 CREATE AN INSTANCE TEMPLATE](https://github.com/JeffDeCola/hello-go-deploy-gce#step-42-create-an-instance-template)\n  * [STEP 4.3 CREATE AN INSTANCE GROUP](https://github.com/JeffDeCola/hello-go-deploy-gce#step-43-create-an-instance-group)\n* [CHECK SERVICES ARE RUNNING](https://github.com/JeffDeCola/hello-go-deploy-gce#check-services-are-running)\n* [CONTINUOUS INTEGRATION \u0026 DEPLOYMENT](https://github.com/JeffDeCola/hello-go-deploy-gce#continuous-integration--deployment)\n\nDocumentation and Reference\n\n* [jeffs-gce-image-ubuntu-2204](https://github.com/JeffDeCola/my-packer-image-builds/tree/master/google-compute-engine-images/jeffs-gce-image-ubuntu-2204)\n  is where I build the gce image\n* The\n  [hello-go-deploy-gce docker image](https://hub.docker.com/r/jeffdecola/hello-go-deploy-gce)\n  on dockerhub\n* My\n  [gce cheat sheet](https://github.com/JeffDeCola/my-cheat-sheets/tree/master/software/service-architectures/infrastructure-as-a-service/google-compute-engine-cheat-sheet)\n  for more detailed information and illustrations\n* This repos\n  [github webpage](https://jeffdecola.github.io/hello-go-deploy-gce/)\n  _built with\n  [concourse](https://github.com/JeffDeCola/hello-go-deploy-gce/blob/master/ci-README.md)_\n\n## OVERVIEW\n\nEvery 2 seconds this App will print,\n\n```txt\n    INFO[0000] Let's Start this!\n    Hello everyone, count is: 1\n    Hello everyone, count is: 2\n    Hello everyone, count is: 3\n    etc...\n```\n\n## PREREQUISITES\n\nYou will need the following go packages,\n\n```bash\ngo get -u -v github.com/sirupsen/logrus\ngo get -u -v github.com/cweill/gotests/...\n```\n\nThis repo contains the packer gce image build scripts,\n\n```bash\ngit clone git@github.com:JeffDeCola/my-packer-image-builds.git\n```\n\n## SOFTWARE STACK\n\n* DEVELOPMENT\n  * [go](https://github.com/JeffDeCola/my-cheat-sheets/tree/master/software/development/languages/go-cheat-sheet)\n* OPERATIONS\n  * [concourse/fly](https://github.com/JeffDeCola/my-cheat-sheets/tree/master/software/operations/continuous-integration-continuous-deployment/concourse-cheat-sheet)\n    (optional)\n  * [docker](https://github.com/JeffDeCola/my-cheat-sheets/tree/master/software/operations/orchestration/builds-deployment-containers/docker-cheat-sheet)\n  * [packer](https://github.com/JeffDeCola/my-cheat-sheets/tree/master/software/operations/orchestration/builds-deployment-containers/packer-cheat-sheet)\n* SERVICES\n  * [dockerhub](https://hub.docker.com/)\n  * [google compute engine (gce)](https://github.com/JeffDeCola/my-cheat-sheets/tree/master/software/service-architectures/infrastructure-as-a-service/google-compute-engine-cheat-sheet)\n\n## RUN\n\nTo\n[run.sh](https://github.com/JeffDeCola/hello-go-deploy-gce/blob/master/hello-go-deploy-gce-code/run.sh),\n\n```bash\ncd hello-go-deploy-gce-code\ngo run main.go\n```\n\nTo\n[create-binary.sh](https://github.com/JeffDeCola/hello-go-deploy-gce/blob/master/hello-go-deploy-gce-code/bin/create-binary.sh),\n\n```bash\ncd hello-go-deploy-gce-code/bin\ngo build -o hello-go ../main.go\n./hello-go\n```\n\nThis binary will not be used during a docker build\nsince it creates it's own.\n\n## STEP 1 - TEST\n\nTo create unit `_test` files,\n\n```bash\ncd hello-go-deploy-gce-code\ngotests -w -all main.go\n```\n\nTo run\n[unit-tests.sh](https://github.com/JeffDeCola/hello-go-deploy-gce/tree/master/hello-go-deploy-gce-code/test/unit-tests.sh),\n\n```bash\ngo test -cover ./... | tee test/test_coverage.txt\ncat test/test_coverage.txt\n```\n\n## STEP 2 - BUILD (DOCKER IMAGE VIA DOCKERFILE)\n\nThis docker image is built in two stages.\nIn **stage 1**, rather than copy a binary into a docker image (because\nthat can cause issues), the Dockerfile will build the binary in the\ndocker image.\nIn **stage 2**, the Dockerfile will copy this binary\nand place it into a smaller docker image based\non `alpine`, which is around 13MB.\n\nTo\n[build.sh](https://github.com/JeffDeCola/hello-go-deploy-gce/blob/master/hello-go-deploy-gce-code/build/build.sh)\nwith a\n[Dockerfile](https://github.com/JeffDeCola/hello-go-deploy-gce/blob/master/hello-go-deploy-gce-code/build/Dockerfile),\n\n```bash\ncd hello-go-deploy-gce-code/build\ndocker build -f Dockerfile -t jeffdecola/hello-go-deploy-gce .\n```\n\nYou can check and test this docker image,\n\n```bash\ndocker images jeffdecola/hello-go-deploy-gce\ndocker run --name hello-go-deploy-gce -dit jeffdecola/hello-go-deploy-gce\ndocker exec -i -t hello-go-deploy-gce /bin/bash\ndocker logs hello-go-deploy-gce\ndocker rm -f hello-go-deploy-gce\n```\n\n## STEP 3 - PUSH (TO DOCKERHUB)\n\nYou must be logged in to DockerHub,\n\n```bash\ndocker login\n```\n\nTo\n[push.sh](https://github.com/JeffDeCola/hello-go-deploy-gce/blob/master/hello-go-deploy-gce-code/push/push.sh),\n\n```bash\ndocker push jeffdecola/hello-go-deploy-gce\n```\n\nCheck the\n[hello-go-deploy-gce docker image](https://hub.docker.com/r/jeffdecola/hello-go-deploy-gce)\nat DockerHub.\n\n## STEP 4 - DEPLOY (TO GCE)\n\nThere are three steps to deploy on gce,\n\n* STEP 4.1 - Build a gce image\n* STEP 4.2 - Create an instance template (HW resources)\n* STEP 4.3 - Create an instance group (Launch VM in region)\n\nFor this example, I will add two running services,\n\n* The dockerhub image runs at boot\n  [hello-go-deploy-gce](https://hub.docker.com/r/jeffdecola/hello-go-deploy-gce/)\n* A binary /home/jeff/hello-go executable runs at boot\n\nTo keep things simple, the files are located in my\n[my-packer-image-builds](https://github.com/JeffDeCola/my-packer-image-builds)\nrepo.\n\n### STEP 4.1 BUILD A CUSTOM MACHINE IMAGE USING PACKER\n\nYou will need to set the following environment variables (I added mine in ~/.bashrc),\n\n```bash\nexport GCP_JEFFS_SERVICE_ACCOUNT_PATH=[path to your google platform .json file]\nexport GCP_JEFFS_PROJECT_ID=[your project id]\n```\n\nTo validate your packer template file\n[template.pkr.hcl](https://github.com/JeffDeCola/my-packer-image-builds/blob/master/google-compute-engine-images/jeffs-gce-image-ubuntu-2204/template.pkr.hcl),\n\n```bash\ncd my-packer-image-builds/google-compute-engine-images/jeffs-gce-image-ubuntu-2204\npacker validate \\\n    -var \"image_name=hello-go-deploy-gce\" \\\n    -var \"account_file=$GCP_JEFFS_SERVICE_ACCOUNT_PATH\" \\\n    -var \"project_id=$GCP_JEFFS_PROJECT_ID\" \\\n    template.pkr.hcl\n```\n\nTo\n[build-image.sh](https://github.com/JeffDeCola/hello-go-deploy-gce/tree/master/hello-go-deploy-gce-code/deploy/build-image.sh)\non gce,\n\n```bash\ncd my-packer-image-builds/google-compute-engine-images/jeffs-gce-image-ubuntu-2204\npacker build \\\n    -var \"image_name=hello-go-deploy-gce\" \\\n    -var \"account_file=$GCP_JEFFS_SERVICE_ACCOUNT_PATH\" \\\n    -var \"project_id=$GCP_JEFFS_PROJECT_ID\" \\\n    template.pkr.hcl\n```\n\nCheck that the image was created at gce,\n\n```bash\ngcloud config set project $GCP_JEFFS_PROJECT_ID\ngcloud compute images list --no-standard-images\n```\n\n### STEP 4.2 CREATE AN INSTANCE TEMPLATE\n\nThe instance template contains the HW resources the instance group needs\nto create the VM instance.\n\nTo\n[create-instance-template](https://github.com/JeffDeCola/my-packer-image-builds/blob/master/google-compute-engine-images/jeffs-gce-image-ubuntu-2204/create-instance-template.sh),\n\n```bash\ncd my-packer-image-builds/google-compute-engine-images/jeffs-gce-image-ubuntu-2204\nsh create-instance-template.sh \"jeffs-hello-go-deploy-gce-image\" \"hello-go-deploy-gce\"\n```\n\nCheck the instance template was created,\n\n```bash\ngcloud compute instance-templates list\n```\n\n### STEP 4.3 CREATE AN INSTANCE GROUP\n\nThe instance group controls the show.\nIt launches and scales your VM instances as needed.\n\nTo\n[create-instance-group](https://github.com/JeffDeCola/my-packer-image-builds/blob/master/google-compute-engine-images/jeffs-gce-image-ubuntu-2204/create-instance-group.sh),\n\n```bash\ncd my-packer-image-builds/google-compute-engine-images/jeffs-gce-image-ubuntu-2204\nsh create-instance-group.sh \"jeffs-hello-go-deploy-gce-instance-template\" \"hello-go-deploy-gce\"\n```\n\nCheck that the instance group and VM instance were created,\n\n```bash\ngcloud compute instance-groups list\ngcloud compute instances list\n```\n\n## CHECK SERVICES ARE RUNNING\n\nTo ssh into your gce VM, I placed my public keys in gce\nmetadata ssh keys, which automatically\nplaces them in the authorized_keys files on my VM,\n\n```bash\nssh -i ~/.ssh/google_compute_engine jeff@\u003cIP\u003e\n```\n\nCheck the docker service is running,\n\n```bash\ndocker ps\ndocker logs -f --tail 10 -f hello-go-deploy-gce\n```\n\nCheck that your hello-go.service is running,\n\n```bash\n# Remember, it kicks off /home/jeff/hello-go\nsystemctl list-unit-files | grep hello.go\nsudo systemctl status hello-go\njournalctl -f\nsudo systemctl stop hello-go\ncat /lib/systemd/system/hello-go.service\nsudo -s\n```\n\nLast, if you have multiple VMS, and since you put the\nsame ssh keys in `/home/jeff/.ssh` when you built the image with packer,\nyour VMs can talk to each other using gce's internal DNS.\n\n```bash\nssh \u003cUSERNAME\u003e@\u003cHOSTNAME\u003e.us-west1-a.c.\u003cPROJECT\u003e.internal\n```\n\n## CONTINUOUS INTEGRATION \u0026 DEPLOYMENT\n\nRefer to\n[ci-README.md](https://github.com/JeffDeCola/hello-go-deploy-gce/blob/master/ci-README.md)\non how I automated the above steps using concourse.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeffdecola%2Fhello-go-deploy-gce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeffdecola%2Fhello-go-deploy-gce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeffdecola%2Fhello-go-deploy-gce/lists"}