-
Notifications
You must be signed in to change notification settings - Fork 21
/
Dockerfile.development
32 lines (27 loc) · 1.44 KB
/
Dockerfile.development
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Stage 1: Build the Go application
FROM golang:1.23.3-bullseye AS build
# Declare the build argument
ARG GIT_COMMIT
WORKDIR /src/stellar-disbursement-platform
ADD go.mod go.sum ./
RUN go mod download
COPY . ./
# Single RUN command to set GIT_COMMIT and use it in build
RUN if [ -z "$GIT_COMMIT" ]; then \
GIT_COMMIT=$(git rev-parse --short HEAD)$( [ -n "$(git status -s)" ] && echo "-dirty-$(id -u -n)" ); \
fi && \
echo "Building with commit: $GIT_COMMIT" && \
go build -o /bin/stellar-disbursement-platform -ldflags "-X main.GitCommit=${GIT_COMMIT}" .
# Stage 2: Setup the development environment with Delve for debugging
FROM golang:1.23.3-bullseye AS development
# set workdir according to repo structure so remote debug source code is in sync
WORKDIR /app/github.com/stellar/stellar-disbursement-platform
RUN apt-get update && apt-get install -y jq && rm -rf /var/lib/apt/lists/*
# Copy the built executable and all source files for debugging
COPY --from=build /bin/stellar-disbursement-platform /app/github.com/stellar/stellar-disbursement-platform/
# Install Delve
RUN go install github.com/go-delve/delve/cmd/dlv@latest
# Ensure the binary has executable permissions
RUN chmod +x /app/github.com/stellar/stellar-disbursement-platform/stellar-disbursement-platform
EXPOSE 8001 2345
ENTRYPOINT ["/go/bin/dlv", "exec", "--continue", "--accept-multiclient", "--headless", "--listen=:2345", "--api-version=2", "--log", "./stellar-disbursement-platform"]