1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-03-31 04:14:59 +00:00

chore: optimize build layers

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
Simon Pasquier 2024-11-05 11:50:31 +01:00
parent 3c35a6d7ba
commit 5cdab7933f
No known key found for this signature in database
GPG key ID: 0190A66C0A10FC4F
3 changed files with 15 additions and 6 deletions

View file

@ -1,16 +1,19 @@
ARG ARCH=amd64
ARG OS=linux
ARG GOLANG_BUILDER=1.23
FROM quay.io/prometheus/golang-builder:${GOLANG_BUILDER}-base AS builder
WORKDIR /workspace
# Copy source files
COPY . .
# Download Go dependencies to reuse the Go cache in subsequent builds.
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go mod download -x && go mod verify
# Build
ARG GOARCH
ENV GOARCH=${GOARCH}
RUN make operator
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build make operator
FROM quay.io/prometheus/busybox-${OS}-${ARCH}:latest

View file

@ -1,16 +1,19 @@
ARG ARCH=amd64
ARG OS=linux
ARG GOLANG_BUILDER=1.23
FROM quay.io/prometheus/golang-builder:${GOLANG_BUILDER}-base AS builder
WORKDIR /workspace
# Copy source files
COPY . .
# Download Go dependencies to reuse the Go cache in subsequent builds.
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go mod download -x && go mod verify
# Build
ARG GOARCH
ENV GOARCH=${GOARCH}
RUN make admission-webhook
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build make admission-webhook
FROM quay.io/prometheus/busybox-${OS}-${ARCH}:latest

View file

@ -1,16 +1,19 @@
ARG ARCH=amd64
ARG OS=linux
ARG GOLANG_BUILDER=1.23
FROM quay.io/prometheus/golang-builder:${GOLANG_BUILDER}-base AS builder
WORKDIR /workspace
# Copy source files
COPY . .
# Download Go dependencies to reuse the Go cache in subsequent builds.
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build go mod download -x && go mod verify
# Build
ARG GOARCH
ENV GOARCH=${GOARCH}
RUN make prometheus-config-reloader
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build make prometheus-config-reloader
FROM quay.io/prometheus/busybox-${OS}-${ARCH}:latest