Add development + debugging docker configs
This commit is contained in:
22
10-development-workflow/api-golang/Dockerfile.dev
Normal file
22
10-development-workflow/api-golang/Dockerfile.dev
Normal file
@ -0,0 +1,22 @@
|
||||
# Pin specific version for stability
|
||||
# using bullseye instead of alpine because of:
|
||||
## runtime/cgo
|
||||
## cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH
|
||||
FROM golang:1.19-bullseye
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install air for hot reload
|
||||
RUN go install github.com/cosmtrek/air@latest
|
||||
|
||||
# Install delve for debugging
|
||||
RUN go install github.com/go-delve/delve/cmd/dlv@latest
|
||||
|
||||
# Copy only files required to install dependencies (better layer caching)
|
||||
COPY go.mod go.sum ./
|
||||
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
CMD ["air", "-c", ".air.toml"]
|
||||
19
10-development-workflow/api-golang/README.md
Normal file
19
10-development-workflow/api-golang/README.md
Normal file
@ -0,0 +1,19 @@
|
||||
Remote debugging setup (vscode `launch.json`):
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "Docker: Attach to Golang",
|
||||
"type": "go",
|
||||
"debugAdapter": "dlv-dap",
|
||||
"mode": "remote",
|
||||
"request": "attach",
|
||||
"port": 4000,
|
||||
"remotePath": "/app",
|
||||
"substitutePath": [
|
||||
{
|
||||
"from": "${workspaceFolder}/docker-course/devops-directive-docker-course/05-example-web-application/api-golang",
|
||||
"to": "/app"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user