ipfs-node-pin/Dockerfile

25 lines
615 B
Docker
Raw Permalink Normal View History

2024-11-08 00:05:22 +00:00
FROM golang:1.23 AS builder
2024-01-04 19:36:26 +00:00
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64
WORKDIR /src
COPY . .
RUN go build \
-ldflags "-s -w -extldflags '-static'" \
-o /bin/app \
.
RUN echo "nobody:x:65534:65534:Nobody:/:" > /etc_passwd
2024-11-07 23:04:59 +00:00
FROM alpine:3.20 as compressor
2024-01-04 19:36:26 +00:00
RUN apk add --no-cache upx binutils
COPY --from=builder --chown=65534:0 /bin/app /app
RUN strip /app && upx -q -9 /app
FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /etc_passwd /etc/passwd
COPY --from=compressor --chown=65534:0 /app /app
USER nobody
ENTRYPOINT ["/app"]