diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..cb016457c --- /dev/null +++ b/.vscode/launch.json @@ -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" + } + ] +} diff --git a/Dockerfile.local b/Dockerfile.local new file mode 100644 index 000000000..7723bda49 --- /dev/null +++ b/Dockerfile.local @@ -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" ] diff --git a/Makefile b/Makefile index 811c60296..d4ff13dd1 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 349d0d34b..a3be3f059 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,7 @@ services: server: build: context: . - dockerfile: Dockerfile + dockerfile: Dockerfile.local container_name: server image: server:local networks: @@ -51,6 +51,7 @@ services: restart: always ports: - '8080:8080' + - '4000:4000' depends_on: - postgres - redis