Skip to content

Commit

Permalink
feat: local dockerfile with dlv debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 committed Nov 15, 2023
1 parent fb6c12c commit 371bc5f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Docker Container",
"type": "go",
"request": "attach",
"mode": "remote",
"port": 4000,
"host": "127.0.0.1"
}
]
}
23 changes: 23 additions & 0 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SPDX-License-Identifier: Apache-2.0

FROM alpine:3.18.4@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 as certs

RUN apk add --update --no-cache ca-certificates

FROM golang:1.21-alpine as go

RUN CGO_ENABLED=0 go install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@latest

FROM scratch

COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt

COPY --from=go /go/bin/dlv /bin/dlv

EXPOSE 8080

ENV GODEBUG=netdns=go

ADD release/vela-server /bin/

CMD [ "/bin/dlv", "--listen=:4000", "--headless=true", "--log=true", "--accept-multiclient", "--api-version=2", "exec", "/bin/vela-server" ]
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ build:
@echo "### Building release/vela-server binary"
GOOS=linux CGO_ENABLED=0 \
go build -a \
-gcflags "all=-N -l" \
-ldflags '${LD_FLAGS}' \
-o release/vela-server \
github.com/go-vela/server/cmd/vela-server
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
server:
build:
context: .
dockerfile: Dockerfile
dockerfile: Dockerfile.local
container_name: server
image: server:local
networks:
Expand Down Expand Up @@ -51,6 +51,7 @@ services:
restart: always
ports:
- '8080:8080'
- '4000:4000'
depends_on:
- postgres
- redis
Expand Down

0 comments on commit 371bc5f

Please sign in to comment.