-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (43 loc) · 1.31 KB
/
Copy pathDockerfile
File metadata and controls
65 lines (43 loc) · 1.31 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
ARG GO_VERSION=1.25.12
ARG BUILDER_ALPINE_VERSION=3.24
ARG ALPINE_VERSION=3.22.5
FROM golang:${GO_VERSION}-alpine${BUILDER_ALPINE_VERSION} AS builder
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY cmd ./cmd
COPY internal ./internal
RUN CGO_ENABLED=0 GOOS=linux go build \
-trimpath \
-ldflags="-s -w" \
-o /out/processing \
./cmd/server
RUN CGO_ENABLED=0 GOOS=linux go build \
-trimpath \
-ldflags="-s -w" \
-o /out/migrate \
./cmd/migrate
RUN CGO_ENABLED=0 GOOS=linux go build \
-trimpath \
-ldflags="-s -w" \
-o /out/seed \
./cmd/seed
FROM alpine:${ALPINE_VERSION} AS runtime-base
RUN apk add --no-cache ca-certificates tzdata \
&& addgroup -S app \
&& adduser -S -G app app
WORKDIR /app
USER app
FROM runtime-base AS migrator
COPY --from=builder --chown=app:app /out/migrate /app/migrate
COPY --chown=app:app migrations /app/migrations
ENTRYPOINT ["/app/migrate"]
FROM runtime-base AS seeder
COPY --from=builder --chown=app:app /out/seed /app/seed
ENTRYPOINT ["/app/seed"]
FROM runtime-base AS app
COPY --from=builder --chown=app:app /out/processing /app/processing
EXPOSE 8080
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 \
CMD wget -q -O /dev/null http://127.0.0.1:8080/health || exit 1
ENTRYPOINT ["/app/processing"]