-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.local
More file actions
59 lines (40 loc) · 1.69 KB
/
Copy pathDockerfile.local
File metadata and controls
59 lines (40 loc) · 1.69 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
# syntax=docker/dockerfile:1.7
FROM golang:1.26.5-alpine3.23 AS builder
ARG CGO_ENABLED=0
ARG SERVICE_VERSION=local-workspace
ARG TARGETOS=linux
ARG TARGETARCH=amd64
ENV GOTOOLCHAIN=local
WORKDIR /src
COPY go.mod go.sum ./service/
COPY --from=core go.mod go.sum ./core/
COPY --from=proto go.mod go.sum ./proto/
RUN go work init ./service ./core ./proto
ENV GOWORK=/src/go.work
RUN --mount=type=cache,target=/go/pkg/mod,sharing=locked \
cd /src/service && go mod download
COPY . ./service/
COPY --from=core . ./core/
COPY --from=proto . ./proto/
RUN cd /src/service && \
core_dir="$(go list -m -f '{{.Dir}}' github.com/invenlore/core)" && \
proto_dir="$(go list -m -f '{{.Dir}}' github.com/invenlore/proto)" && \
printf "local module github.com/invenlore/core -> %s\n" "$core_dir" && \
printf "local module github.com/invenlore/proto -> %s\n" "$proto_dir" && \
test "$core_dir" = "/src/core" && \
test "$proto_dir" = "/src/proto"
RUN --mount=type=cache,target=/go/pkg/mod,sharing=locked \
--mount=type=cache,target=/root/.cache/go-build,sharing=locked \
mkdir -p /out && \
cd /src/service && \
CGO_ENABLED="$CGO_ENABLED" GOOS="$TARGETOS" GOARCH="$TARGETARCH" \
go build -mod=readonly -trimpath -buildvcs=false -o /out/gateway .
RUN printf "%s" "$SERVICE_VERSION" > /out/version.txt
FROM scratch
WORKDIR /app
COPY --from=builder /out/gateway ./gateway
COPY --from=builder /out/version.txt ./version.txt
COPY --from=ghcr.io/tarampampam/microcheck:1 /bin/httpcheck /bin/httpcheck
USER 65532:65532
HEALTHCHECK --interval=1m --timeout=5s --start-period=10s --retries=3 CMD ["/bin/httpcheck", "--port-env=HEALTH_PORT", "http://localhost/health"]
ENTRYPOINT ["/app/gateway"]