Skip to content

Commit 8526c62

Browse files
Merge pull request #3 from super-phenix/dockerfile
feat(docker): add dockerfile
2 parents 1b6a705 + 73b1711 commit 8526c62

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
ARG PROJECT=volume-replicator
2+
3+
FROM golang:1.25.5-trixie AS build
4+
5+
ARG PROJECT
6+
ARG USER=$PROJECT
7+
ARG UID=1000
8+
9+
RUN adduser \
10+
--disabled-password \
11+
--gecos "" \
12+
--home "/nonexistent" \
13+
--shell "/sbin/nologin" \
14+
--no-create-home \
15+
--uid $UID \
16+
$USER
17+
18+
WORKDIR $GOPATH/src/$PROJECT/
19+
COPY . .
20+
21+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags '-w -s' -o /bin/main main.go
22+
23+
FROM scratch
24+
25+
ARG PROJECT
26+
WORKDIR /
27+
28+
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
29+
COPY --from=build /usr/share/zoneinfo /usr/share/zoneinfo
30+
COPY --from=build /etc/passwd /etc/passwd
31+
COPY --from=build /etc/group /etc/group
32+
33+
WORKDIR /app
34+
35+
COPY --from=build /bin/main volume-replicator
36+
37+
USER $USER:$USER
38+
39+
ENTRYPOINT ["/app/volume-replicator"]
40+
41+
42+

0 commit comments

Comments
 (0)