Standard Go Project Template

This is a template for Go application projects based on Standard Go Project Layout.

Build, run and debug application locally

Build, run and debug application with docker

Create environment file for docker

Create and fill environment file from template .env.dist

cp .env.dist .env.docker

Build docker container

Build container

docker build . -t psssix/golang-app:latest

and container with debugger

docker build . -f Debug.Dockerfile -t psssix/golang-app:debug

Push container

docker push psssix/golang-app:latest

Run docker container

Run container on docker

docker run -d --name golang-app --env-file .env.docker psssix/golang-app:latest

and container with debugger

docker run -d --name golang-app --security-opt="apparmor=unconfined" --cap-add=SYS_PTRACE -p 4040:4040 --env-file .env.docker psssix/golang-app:debug

Debug docker container

  1. Create and fill .env.docker file by template .env.dist.
  2. Build docker container with debugger.
  3. Run container on docker with debugger.
  4. Play debug configuration names as "debug remote docker container".
Description
Standard Go Project Template with multistage building
Readme 51 KiB
2023-07-26 19:18:42 +03:00
Languages
Go 37.6%
Dockerfile 30.1%
Shell 27.2%
Makefile 5.1%