app-cloudep-notification-se.../build/Dockerfile

47 lines
951 B
Docker
Raw Normal View History

2024-08-20 06:12:13 +00:00
###########
# BUILDER #
###########
2024-08-20 10:05:39 +00:00
FROM golang:1.22.3 as builder
2024-08-20 06:12:13 +00:00
ARG VERSION
ARG BUILT
ARG GIT_COMMIT
2024-08-20 10:05:39 +00:00
ARG SSH_PRV_KEY
2024-08-20 06:12:13 +00:00
2024-08-20 10:05:39 +00:00
# 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}"
2024-08-20 06:12:13 +00:00
WORKDIR /app
COPY . .
2024-08-20 10:05:39 +00:00
RUN apt-get update && \
apt-get install git
2024-08-20 06:12:13 +00:00
2024-08-20 10:05:39 +00:00
# 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
2024-08-20 06:12:13 +00:00
2024-08-20 10:05:39 +00:00
RUN --mount=type=ssh go mod download
2024-08-20 06:12:13 +00:00
2024-08-20 10:05:39 +00:00
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags "$FLAG" \
2024-08-27 14:24:56 +00:00
-o notification
2024-08-20 06:12:13 +00:00
2024-08-20 10:05:39 +00:00
##########
## FINAL #
##########
#
FROM gcr.io/distroless/static-debian11
2024-08-20 06:12:13 +00:00
WORKDIR /app
2024-08-20 10:05:39 +00:00
COPY --from=builder /app/service /app/service
COPY --from=builder /app/etc/service.yaml /app/etc/service.yaml
EXPOSE 8080
2024-08-27 14:24:56 +00:00
CMD ["/app/notification"]