2022-08-07 00:47:11 +03:00
|
|
|
# Standard Go Project Template
|
|
|
|
|
This is a template for Go application projects based on [Standard Go Project Layout](https://github.com/golang-standards/project-layout).
|
|
|
|
|
|
|
|
|
|
### Build, run and debug application locally
|
|
|
|
|
|
2022-08-07 00:59:03 +03:00
|
|
|
#### Create environment file
|
|
|
|
|
Create and fill environment file from template `.env.dist`
|
|
|
|
|
``` shell
|
|
|
|
|
cp .env.dist .env
|
|
|
|
|
```
|
|
|
|
|
|
2022-08-07 00:47:11 +03:00
|
|
|
### Build, run and debug application with docker
|
|
|
|
|
|
|
|
|
|
#### Create environment file for docker
|
|
|
|
|
Create and fill environment file from template `.env.dist`
|
|
|
|
|
``` shell
|
|
|
|
|
cp .env.dist .env.docker
|
|
|
|
|
```
|
|
|
|
|
|
2021-02-20 00:39:46 +03:00
|
|
|
#### Build docker container
|
|
|
|
|
Build container
|
2022-08-07 00:47:11 +03:00
|
|
|
``` shell
|
2021-02-20 00:39:46 +03:00
|
|
|
docker build . -t psssix/golang-app:latest
|
|
|
|
|
```
|
2022-08-07 00:20:37 +03:00
|
|
|
and container with debugger
|
2022-08-07 00:47:11 +03:00
|
|
|
``` shell
|
2022-08-07 00:20:37 +03:00
|
|
|
docker build . -f Debug.Dockerfile -t psssix/golang-app:debug
|
|
|
|
|
```
|
|
|
|
|
|
2021-02-20 00:39:46 +03:00
|
|
|
Push container
|
2022-08-07 00:47:11 +03:00
|
|
|
``` shell
|
2021-02-20 00:39:46 +03:00
|
|
|
docker push psssix/golang-app:latest
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### Run docker container
|
2022-08-03 23:17:49 +03:00
|
|
|
Run container on docker
|
2022-08-07 00:47:11 +03:00
|
|
|
``` shell
|
2022-08-07 00:20:37 +03:00
|
|
|
docker run -d --name golang-app --env-file .env.docker psssix/golang-app:latest
|
|
|
|
|
```
|
|
|
|
|
and container with debugger
|
2022-08-07 00:47:11 +03:00
|
|
|
``` shell
|
2022-08-07 00:20:37 +03:00
|
|
|
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
|
2022-08-07 00:47:11 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### 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".
|