outposts: use buildkit cache for dependencies and intermediate build artifacts
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
parent
e507a38d43
commit
2fdafca4eb
|
@ -3,9 +3,17 @@ FROM docker.io/golang:1.21.1-bookworm AS builder
|
||||||
|
|
||||||
WORKDIR /go/src/goauthentik.io
|
WORKDIR /go/src/goauthentik.io
|
||||||
|
|
||||||
COPY . .
|
COPY go.mod .
|
||||||
|
COPY go.sum .
|
||||||
|
COPY gen-go-api .
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||||
|
go mod download
|
||||||
|
|
||||||
ENV CGO_ENABLED=0
|
ENV CGO_ENABLED=0
|
||||||
RUN go build -o /go/ldap ./cmd/ldap
|
COPY . .
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||||
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
|
go build -o /go/ldap ./cmd/ldap
|
||||||
|
|
||||||
# Stage 2: Run
|
# Stage 2: Run
|
||||||
FROM gcr.io/distroless/static-debian11:debug
|
FROM gcr.io/distroless/static-debian11:debug
|
||||||
|
|
|
@ -1,21 +1,34 @@
|
||||||
# Stage 1: Build website
|
# Stage 1: Build website
|
||||||
FROM --platform=${BUILDPLATFORM} docker.io/node:20.5 as web-builder
|
FROM --platform=${BUILDPLATFORM} docker.io/node:20.5 as web-builder
|
||||||
|
|
||||||
COPY ./web /static/
|
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
WORKDIR /static
|
WORKDIR /static
|
||||||
RUN npm ci --include=dev && npm run build-proxy
|
|
||||||
|
COPY web/package.json .
|
||||||
|
COPY web/package-lock.json .
|
||||||
|
RUN --mount=type=cache,target=/static/.npm \
|
||||||
|
npm set cache /static/.npm && \
|
||||||
|
npm ci --include=dev
|
||||||
|
|
||||||
|
COPY web .
|
||||||
|
RUN npm run build-proxy
|
||||||
|
|
||||||
# Stage 2: Build
|
# Stage 2: Build
|
||||||
FROM docker.io/golang:1.21.1-bookworm AS builder
|
FROM docker.io/golang:1.21.1-bookworm AS builder
|
||||||
|
|
||||||
WORKDIR /go/src/goauthentik.io
|
WORKDIR /go/src/goauthentik.io
|
||||||
|
|
||||||
COPY . .
|
COPY go.mod .
|
||||||
|
COPY go.sum .
|
||||||
|
COPY gen-go-api .
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||||
|
go mod download
|
||||||
|
|
||||||
ENV CGO_ENABLED=0
|
ENV CGO_ENABLED=0
|
||||||
RUN go build -o /go/proxy ./cmd/proxy
|
COPY . .
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||||
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
|
go build -o /go/proxy ./cmd/proxy
|
||||||
|
|
||||||
# Stage 3: Run
|
# Stage 3: Run
|
||||||
FROM gcr.io/distroless/static-debian11:debug
|
FROM gcr.io/distroless/static-debian11:debug
|
||||||
|
|
|
@ -3,9 +3,17 @@ FROM docker.io/golang:1.21.1-bookworm AS builder
|
||||||
|
|
||||||
WORKDIR /go/src/goauthentik.io
|
WORKDIR /go/src/goauthentik.io
|
||||||
|
|
||||||
COPY . .
|
COPY go.mod .
|
||||||
|
COPY go.sum .
|
||||||
|
COPY gen-go-api .
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||||
|
go mod download
|
||||||
|
|
||||||
ENV CGO_ENABLED=0
|
ENV CGO_ENABLED=0
|
||||||
RUN go build -o /go/radius ./cmd/radius
|
COPY . .
|
||||||
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||||
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
|
go build -o /go/radius ./cmd/radius
|
||||||
|
|
||||||
# Stage 2: Run
|
# Stage 2: Run
|
||||||
FROM gcr.io/distroless/static-debian11:debug
|
FROM gcr.io/distroless/static-debian11:debug
|
||||||
|
|
Reference in New Issue