42 lines
835 B
Docker
42 lines
835 B
Docker
|
###########
|
||
|
# BUILDER #
|
||
|
###########
|
||
|
|
||
|
FROM golang:1.23.4 AS builder
|
||
|
|
||
|
ARG VERSION
|
||
|
ARG BUILT
|
||
|
ARG GIT_COMMIT
|
||
|
|
||
|
# private go packages
|
||
|
ENV GOPRIVATE=code.30cm.net
|
||
|
ENV FLAG="-s -w -X main.Version=${VERSION} -X main.Built=${BUILT} -X main.GitCommit=${GIT_COMMIT}"
|
||
|
WORKDIR /app
|
||
|
COPY . .
|
||
|
|
||
|
|
||
|
RUN apt-get update && \
|
||
|
apt-get install -y git
|
||
|
|
||
|
# Make the root foler for our ssh
|
||
|
RUN --mount=type=secret,id=ssh_key,dst=/root/.ssh/id_rsa \
|
||
|
ssh-keyscan git.30cm.net >> /root/.ssh/known_hosts
|
||
|
|
||
|
|
||
|
RUN --mount=type=ssh go mod download
|
||
|
|
||
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||
|
-ldflags "$FLAG" \
|
||
|
-o member
|
||
|
|
||
|
##########
|
||
|
## FINAL #
|
||
|
##########
|
||
|
#
|
||
|
FROM gcr.io/distroless/static-debian11
|
||
|
WORKDIR /app
|
||
|
|
||
|
COPY --from=builder /app/member /app/member
|
||
|
COPY --from=builder /app/etc/member.yaml /app/etc/member.yaml
|
||
|
EXPOSE 8080
|
||
|
CMD ["/app/member"]
|