33 lines
873 B
Docker
33 lines
873 B
Docker
# ---------- Builder Stage ----------
|
|
FROM golang:1.24.2 AS builder
|
|
ARG GIT_AUTH_TOKEN
|
|
RUN git config --global url."https://${GIT_AUTH_TOKEN}:x-oauth-basic@git.denco.store/".insteadOf "https://git.denco.store/"
|
|
|
|
WORKDIR /app
|
|
|
|
# copy only go.mod and go.sum first
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
# now copy the rest of the code
|
|
COPY . .
|
|
|
|
# build binaries
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -o server ./cmd/server/main.go \
|
|
&& CGO_ENABLED=0 GOOS=linux go build -o tasks_server ./cmd/tasks_server/main.go
|
|
|
|
|
|
|
|
# ---------- Final Image: Server ----------
|
|
FROM gcr.io/distroless/static-debian12 AS server
|
|
WORKDIR /app
|
|
COPY --from=builder /app/server .
|
|
ENTRYPOINT ["./server"]
|
|
|
|
|
|
# ---------- Final Image: Tasks Server ----------
|
|
FROM gcr.io/distroless/static-debian12 AS tasks_server
|
|
WORKDIR /app
|
|
COPY --from=builder /app/tasks_server .
|
|
ENTRYPOINT ["./tasks_server"]
|