app-cloudep-permission-server/build/Dockerfile

43 lines
885 B
Docker
Raw Permalink Normal View History

###########
# BUILDER #
###########
2025-02-13 11:06:51 +00:00
FROM golang:1.24.0 AS builder
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
# 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
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
##########
## 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
EXPOSE 8080
2025-02-12 01:51:46 +00:00
CMD ["/app/permission"]