-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
56 lines (51 loc) · 2.09 KB
/
Dockerfile
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
# This Dockerfile requires DOCKER_BUILDKIT=1 to be build.
# We do not use syntax header so that we do not have to wait
# for the Dockerfile frontend image to be pulled.
FROM node:20.17-alpine3.19 as node-build
RUN apk --update add make bash
COPY . /src/peerdb
WORKDIR /src/peerdb
RUN \
npm install -g npm@latest && \
npm ci --audit=false && \
npm audit signatures && \
make dist
FROM golang:1.23-alpine3.19 AS go-build
RUN apk --update add make bash git gcc musl-dev ca-certificates tzdata mailcap && \
adduser -D -H -g "" -s /sbin/nologin -u 1000 user
COPY . /src/peerdb
# We make an empty node_modules so that Makefile does not try to run npm install (dist files are
# copied next). It has to be made before COPY so that it looks older than dist to make.
RUN mkdir /src/peerdb/node_modules
COPY --from=node-build /src/peerdb/dist /src/peerdb/dist
WORKDIR /src/peerdb
# We want Docker image for build timestamp label to match the one in
# the binary so we take a timestamp once outside and pass it in.
ARG BUILD_TIMESTAMP
RUN \
BUILD_TIMESTAMP=$BUILD_TIMESTAMP make build-static && \
mv peerdb /go/bin/peerdb
FROM alpine:3.18 AS debug
COPY --from=go-build /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=go-build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=go-build /etc/mime.types /etc/mime.types
COPY --from=go-build /etc/passwd /etc/passwd
COPY --from=go-build /etc/group /etc/group
COPY --from=go-build /go/bin/peerdb /
USER user:user
EXPOSE 8080
ENTRYPOINT ["/peerdb"]
FROM scratch AS production
RUN --mount=from=busybox:1.36-musl,src=/bin/,dst=/bin/ ["/bin/mkdir", "-m", "1755", "/tmp"]
COPY --from=go-build /etc/services /etc/services
COPY --from=go-build /etc/protocols /etc/protocols
# The rest is the same as for the debug image.
COPY --from=go-build /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=go-build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=go-build /etc/mime.types /etc/mime.types
COPY --from=go-build /etc/passwd /etc/passwd
COPY --from=go-build /etc/group /etc/group
COPY --from=go-build /go/bin/peerdb /
USER user:user
EXPOSE 8080
ENTRYPOINT ["/peerdb"]