48 lines
1.1 KiB
Docker
48 lines
1.1 KiB
Docker
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.24@sha256:d9db32125db0c3a680cfb7a1afcaefb89c898a075ec148fdc2f0f646cc2ed509 AS build
|
|
|
|
ARG TARGETPLATFORM
|
|
ARG BUILDPLATFORM
|
|
ARG TARGETOS
|
|
ARG TARGETARCH
|
|
|
|
WORKDIR /workspace
|
|
|
|
RUN apt update -qq && apt install -qq -y git bash curl g++
|
|
|
|
# Download libraries
|
|
ADD go.* .
|
|
RUN go mod download
|
|
|
|
# Build
|
|
ADD cmd cmd
|
|
ADD internal internal
|
|
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o webhook -ldflags '-w -extldflags "-static"' -o openmcpauthproxy ./cmd/proxy
|
|
|
|
#Test
|
|
RUN CGO_ENABLED=1 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go test -v -race ./...
|
|
|
|
|
|
# Build production container
|
|
FROM --platform=${BUILDPLATFORM:-linux/amd64} ubuntu:24.04
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install --no-install-recommends -y \
|
|
python3-pip \
|
|
python-is-python3 \
|
|
npm \
|
|
&& apt-get autoremove \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN pip install uvenv --break-system-packages
|
|
|
|
WORKDIR /app
|
|
COPY --from=build /workspace/openmcpauthproxy /app/
|
|
|
|
ADD config.yaml /app
|
|
|
|
|
|
ENTRYPOINT ["/app/openmcpauthproxy"]
|
|
|
|
ARG IMAGE_SOURCE
|
|
LABEL org.opencontainers.image.source=$IMAGE_SOURCE
|