golang-template-repo
golang-template-repo copied to clipboard
Template repository for starting a project on Go + Docker + Google cloud stack
GoLang + Docker + Google Cloud Run template repository

Basic development
- Init using your preferred GoLang module name, for example,
make init NAME=github.com/ashishb/golang-template-repo
- Write the code in
src/
- Format it using
make format
- Lint it using
make lint
- Build it using
make build
. If required, clean it usingmake clean
- If you have written any tests then test using
make test
- Run using
make run
- Note: If you are on Mac OS, you can explicitly build for 64-bit GNU/Linux using
make build_linux
Docker
- Build docker image using
make docker_build
- Test using
make docker_run
Google cloud run deployment
- Create a new project on Google Cloud
- Put the project ID (not project name) in
GOOGLE_CLOUD_PROJECT_NAME
variable in Makefile - Create a new Cloud run service at https://console.cloud.google.com/run
- Put the cloud run service name in
GOOGLE_CLOUD_RUN_SERVICE_NAME
variable in Makefile - Install google-cloud-sdk
- Run
make docker_gcr_login
. This is only required only once on your Google Cloud SDK installation - Now, push your local image to Google Cloud registry using
make docker_gcr_push
- And deploy the image using
make gcloud_deploy