2024-08-24 07:14:58 +00:00
|
|
|
###########
|
|
|
|
# BUILDER #
|
|
|
|
###########
|
|
|
|
|
2025-02-13 11:06:51 +00:00
|
|
|
FROM golang:1.24.0 AS builder
|
2024-08-24 07:14:58 +00:00
|
|
|
|
|
|
|
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 && \
|
2025-02-12 01:51:46 +00:00
|
|
|
apt-get install -y git && \
|
|
|
|
mkdir /root/.ssh
|
2024-08-24 07:14:58 +00:00
|
|
|
|
|
|
|
# Make the root foler for our ssh
|
2025-02-12 01:51:46 +00:00
|
|
|
RUN --mount=type=secret,id=ssh_key,dst=/root/.ssh/id_rsa \
|
|
|
|
ssh-keyscan git.30cm.net >> /root/.ssh/known_hosts
|
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-02-12 01:51:46 +00:00
|
|
|
-o permission
|
2024-08-24 07:14:58 +00:00
|
|
|
|
|
|
|
##########
|
|
|
|
## FINAL #
|
|
|
|
##########
|
|
|
|
#
|
|
|
|
FROM gcr.io/distroless/static-debian11
|
|
|
|
WORKDIR /app
|
|
|
|
|
2025-02-12 01:51: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-02-12 01:51:46 +00:00
|
|
|
CMD ["/app/permission"]
|