app-cloudep-member-server/build/Dockerfile

47 lines
935 B
Docker

###########
# BUILDER #
###########
FROM golang:1.22.3 as builder
ARG VERSION
ARG BUILT
ARG GIT_COMMIT
ARG SSH_PRV_KEY
# 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 git
# Make the root foler for our ssh
RUN mkdir -p /root/.ssh && \
chmod 0700 /root/.ssh && \
ssh-keyscan git.30cm.net > /root/.ssh/known_hosts && \
echo "$SSH_PRV_KEY" > /root/.ssh/id_rsa && \
chmod 600 /root/.ssh/id_rsa
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"]