app-cloudep-member-server/build/Dockerfile

47 lines
935 B
Docker
Raw Permalink Normal View History

2024-08-22 14:27:13 +00:00
###########
# 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" \
2024-08-25 14:08:56 +00:00
-o member
2024-08-22 14:27:13 +00:00
##########
## FINAL #
##########
#
FROM gcr.io/distroless/static-debian11
WORKDIR /app
2024-08-25 14:08:56 +00:00
COPY --from=builder /app/member /app/member
COPY --from=builder /app/etc/member.yaml /app/etc/member.yaml
2024-08-22 14:27:13 +00:00
EXPOSE 8080
2024-08-25 14:08:56 +00:00
CMD ["/app/member"]