-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.nodemon
More file actions
44 lines (38 loc) · 1.48 KB
/
Dockerfile.nodemon
File metadata and controls
44 lines (38 loc) · 1.48 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
# Build the zxporter-nodemon binary
FROM golang:1.24 as builder
ARG TARGETOS
ARG TARGETARCH
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
# Copy the go source
COPY cmd/ cmd/
COPY internal/ internal/
COPY gen/ gen/
# Version build args
ARG MAJOR=0
ARG MINOR=0
ARG PATCH=1
ARG COMMIT_HASH=unknown
ARG GIT_TREE_STATE=unknown
ARG BUILD_DATE=unknown
# Build
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} GO_VERSION=$(go version | awk '{print $3}') go build \
-ldflags "-X github.com/devzero-inc/zxporter/internal/version.major=${MAJOR} \
-X github.com/devzero-inc/zxporter/internal/version.minor=${MINOR} \
-X github.com/devzero-inc/zxporter/internal/version.patch=${PATCH} \
-X github.com/devzero-inc/zxporter/internal/version.gitCommit=${COMMIT_HASH} \
-X github.com/devzero-inc/zxporter/internal/version.gitTreeState=${GIT_TREE_STATE} \
-X github.com/devzero-inc/zxporter/internal/version.buildDate=${BUILD_DATE} \
-X github.com/devzero-inc/zxporter/internal/version.goVersion=${GO_VERSION}" \
-a -o zxporter-nodemon cmd/zxporter-nodemon/main.go
# Use distroless nonroot as minimal base image.
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/zxporter-nodemon .
USER 65532:65532
ENTRYPOINT ["/zxporter-nodemon"]