From 10d1b4850515b2e79e0876b07a6ba5d4c53420d3 Mon Sep 17 00:00:00 2001 From: Stavros Date: Fri, 11 Jul 2025 17:15:32 +0300 Subject: [PATCH] chore: add dlv for debugging in dev workflow --- .gitignore | 3 --- .vscode/launch.json | 15 +++++++++++++++ Dockerfile.dev | 1 + air.toml | 4 ++-- docker-compose.dev.yml | 1 + 5 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.gitignore b/.gitignore index ec50bdf..0100a13 100644 --- a/.gitignore +++ b/.gitignore @@ -13,9 +13,6 @@ users.txt # secret test file secret* -# vscode -.vscode - # apple stuff .DS_Store diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..781201b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Connect to server", + "type": "go", + "request": "attach", + "mode": "remote", + "remotePath": "/tinyauth", + "port": 4000, + "host": "127.0.0.1", + "debugAdapter": "legacy" + } + ] +} diff --git a/Dockerfile.dev b/Dockerfile.dev index 82cba68..2a3ab15 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -13,6 +13,7 @@ COPY ./main.go ./ COPY ./air.toml ./ RUN go install github.com/air-verse/air@v1.61.7 +RUN go install github.com/go-delve/delve/cmd/dlv@v1.25.0 EXPOSE 3000 diff --git a/air.toml b/air.toml index d9c0f27..466d56e 100644 --- a/air.toml +++ b/air.toml @@ -3,8 +3,8 @@ tmp_dir = "tmp" [build] pre_cmd = ["mkdir -p internal/assets/dist", "echo 'backend running' > internal/assets/dist/index.html"] -cmd = "CGO_ENABLED=0 go build -o ./tmp/tinyauth ." -bin = "tmp/tinyauth" +cmd = "CGO_ENABLED=0 go build -gcflags=\"all=-N -l\" -o ./tinyauth ." +bin = "/go/bin/dlv --listen :4000 --headless=true --api-version=2 --accept-multiclient --log=true exec ./tinyauth" include_ext = ["go"] exclude_dir = ["internal/assets/dist"] exclude_regex = [".*_test\\.go"] diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index a93076d..33b1000 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -42,6 +42,7 @@ services: - /var/run/docker.sock:/var/run/docker.sock ports: - 3000:3000 + - 4000:4000 labels: traefik.enable: true traefik.http.middlewares.tinyauth.forwardauth.address: http://tinyauth-backend:3000/api/auth/traefik