-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (26 loc) · 767 Bytes
/
Dockerfile
File metadata and controls
43 lines (26 loc) · 767 Bytes
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
33
34
35
36
37
38
39
40
41
42
43
# syntax=docker/dockerfile:1
# Build the application from source
FROM golang:1.26 AS build-stage
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY cmd/ cmd/
COPY internal/ internal/
RUN CGO_ENABLED=0 GOOS=linux go build -o api ./cmd/api/
RUN CGO_ENABLED=0 GOOS=linux go build -o worker ./cmd/worker/
# Run the tests in the container
FROM build-stage AS run-test-stage
RUN go test -v ./...
# Deploy the API binary into a lean image
FROM scratch AS build-release-stage
WORKDIR /
COPY --from=build-stage /app/api /api
EXPOSE 1323
USER 65532:65532
ENTRYPOINT ["/api"]
# Deploy the worker binary into a lean image
FROM scratch AS worker-release-stage
WORKDIR /
COPY --from=build-stage /app/worker /worker
USER 65532:65532
ENTRYPOINT ["/worker"]