ark-member/build/Dockerfile

44 lines
1.1 KiB
Docker

FROM golang:1.22 AS builder
LABEL stage=gobuilder
ENV CGO_ENABLED 0
RUN apt-get update && \
apt-get install git
WORKDIR /build
#
## Download public key for yt.com
#RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan code.30cm.net >> ~/.ssh/known_hosts
#
## Forces the usage of git and ssh key fwded by ssh-agent for yt.com git repos
#RUN git config --global url."git@git.30cm.net:".insteadOf "https://code.30cm.net"
#
## private go packages
#ENV GOPRIVATE=code.30cm.net
ADD ../go.mod .
ADD ../go.sum .
RUN --mount=type=ssh go mod download
ENV FLAG="-s -w -X main.Version=${VERSION} -X main.Built=${BUILT} -X main.GitCommit=${GIT_COMMIT}"
COPY .. .
COPY ../etc /app/etc
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags "$FLAG" \
-o /app/member member.go
FROM gcr.io/distroless/static-debian12
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /usr/share/zoneinfo/Asia/Taipei /usr/share/zoneinfo/Asia/Taipei
ENV TZ Asia/Taipei
WORKDIR /app
COPY --from=builder /app/member /app/member
COPY --from=builder /app/etc /app/etc
CMD ["./member", "-f", "etc/member.yaml"]