2024-08-24 07:14:58 +00:00
|
|
|
###########
|
|
|
|
# BUILDER #
|
|
|
|
###########
|
|
|
|
|
2025-03-12 07:30:43 +00:00
|
|
|
FROM golang:1.24.0 as builder
|
2024-08-24 07:14:58 +00:00
|
|
|
|
|
|
|
ARG VERSION
|
|
|
|
ARG BUILT
|
|
|
|
ARG GIT_COMMIT
|
2025-03-12 07:30:43 +00:00
|
|
|
ARG SSH_PRV_KEY
|
2024-08-24 07:14:58 +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}"
|
|
|
|
WORKDIR /app
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
|
|
|
|
RUN apt-get update && \
|
2025-03-12 07:30:43 +00:00
|
|
|
apt-get install git
|
2024-08-24 07:14:58 +00:00
|
|
|
|
|
|
|
# Make the root foler for our ssh
|
2025-03-12 07:30:43 +00:00
|
|
|
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-24 07:14:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
RUN --mount=type=ssh go mod download
|
|
|
|
|
|
|
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
|
|
|
-ldflags "$FLAG" \
|
2025-03-05 07:10:46 +00:00
|
|
|
-o permission
|
2024-08-24 07:14:58 +00:00
|
|
|
|
|
|
|
##########
|
|
|
|
## FINAL #
|
|
|
|
##########
|
|
|
|
#
|
|
|
|
FROM gcr.io/distroless/static-debian11
|
|
|
|
WORKDIR /app
|
|
|
|
|
2025-03-05 07:10:46 +00:00
|
|
|
COPY --from=builder /app/permission /app/permission
|
|
|
|
COPY --from=builder /app/etc/permission.yaml /app/etc/permission.yaml
|
2024-08-24 07:14:58 +00:00
|
|
|
EXPOSE 8080
|
2025-03-05 07:10:46 +00:00
|
|
|
CMD ["/app/permission"]
|