Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Debug config for both local and dockerized dev set-ups to make it easier to debug and develop. #1630

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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