Skip to content

Commit

Permalink
added debug config for docker and local, to make it easier to debug y…
Browse files Browse the repository at this point in the history
…agpdb (#1630)

Co-authored-by: Ashish Jhanwar <[email protected]>
  • Loading branch information
ashishjh-bst and ashishjh-bst authored Apr 9, 2024
1 parent 7098ec2 commit b27cd29
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ cmd/shardorchestrator/shardorchestrator
*.agent
*.exe
cmd/shardorchestrator/capturepanics
__debug_bin*
app.env
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "YAGPDB Docker Debug",
"type": "go",
"request": "attach",
"port": 4000,
"host": "127.0.0.1",
"cwd": "${workspaceRoot}",
"showLog": true,
"mode": "remote",
"remotePath": "/app/yagpdb/",
"substitutePath": [
{ "from": "${workspaceFolder}", "to": "/app/yagpdb" },
]
}, {
"name": "YAGPDB Local Debug",
"type":"go",
"request": "launch",
"mode": "debug",
"envFile": "${workspaceFolder}/app.env",
"program": "${workspaceFolder}/cmd/yagpdb/main.go",
"output": "${workspaceFolder}/cmd/yagpdb/yagpdb",
"args": ["-all","https=false"]
}
]
}
17 changes: 17 additions & 0 deletions yagpdb_docker/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM golang:1.22.2-alpine
# Dependencies: ca-certificates for client TLS, tzdata for timezone and ffmpeg for soundboard support
RUN apk --no-cache add ca-certificates ffmpeg tzdata
RUN CGO_ENABLED=0 go install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@latest

WORKDIR /app/yagpdb
COPY go.mod go.sum ./
RUN go mod download

COPY . .

WORKDIR /app/yagpdb/cmd/yagpdb

VOLUME ["/app/soundboard", "/app/cert"]
EXPOSE 5000 4000
EXPOSE 5100-5999
CMD [ "/go/bin/dlv", "--listen=:4000", "--headless=true", "--log=true", "--accept-multiclient", "--api-version=2", "debug", "--continue", "--output=yagpdb", "--", "-all", "-https=false" ]
54 changes: 54 additions & 0 deletions yagpdb_docker/docker-compose.debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
version: '3'

volumes:
db:
redis:
cert_cache:
soundboard:

networks:
default:

services:
app:
build:
# We change context so that we can copy the local repo in during
# development
context: ../
dockerfile: yagpdb_docker/Dockerfile.debug
restart: unless-stopped
depends_on:
- redis
- db
networks:
- default
volumes:
- cert_cache:/app/cert
- soundboard:/app/soundboard
- ..:/app/yagpdb
ports:
- '5000:5000'
- '4000:4000'
- '5100-5999:5100-5999'
env_file:
- app.env
security_opt:
- "seccomp:unconfined"

redis:
image: redis
restart: unless-stopped
networks:
- default
volumes:
- redis:/data

db:
image: postgres:11
restart: unless-stopped
volumes:
- db:/var/lib/postgresql/data
networks:
- default
env_file:
- db.env

0 comments on commit b27cd29

Please sign in to comment.