mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00
fix github action caching
This commit is contained in:
parent
4af2eaa6a3
commit
8d06f7cf02
1 changed files with 17 additions and 15 deletions
32
Dockerfile
32
Dockerfile
|
@ -1,5 +1,5 @@
|
||||||
# Stage 1: Builder
|
# Stage 1: deps
|
||||||
FROM golang:1.24.0-alpine AS builder
|
FROM golang:1.24.0-alpine AS deps
|
||||||
HEALTHCHECK NONE
|
HEALTHCHECK NONE
|
||||||
|
|
||||||
# package version does not matter
|
# package version does not matter
|
||||||
|
@ -11,17 +11,19 @@ WORKDIR /src
|
||||||
# Only copy go.mod and go.sum initially for better caching
|
# Only copy go.mod and go.sum initially for better caching
|
||||||
COPY go.mod go.sum /src/
|
COPY go.mod go.sum /src/
|
||||||
|
|
||||||
# Utilize build cache
|
ENV GOPATH=/root/go
|
||||||
RUN --mount=type=cache,target="/go/pkg/mod" \
|
RUN go mod download -x
|
||||||
go mod download -x
|
|
||||||
|
|
||||||
ENV GOCACHE=/root/.cache/go-build
|
# Stage 2: builder
|
||||||
|
FROM deps AS builder
|
||||||
|
|
||||||
COPY Makefile /src/
|
WORKDIR /src
|
||||||
COPY cmd /src/cmd
|
|
||||||
COPY internal /src/internal
|
COPY Makefile ./
|
||||||
COPY pkg /src/pkg
|
COPY cmd ./cmd
|
||||||
COPY agent /src/agent
|
COPY internal ./internal
|
||||||
|
COPY pkg ./pkg
|
||||||
|
COPY agent ./agent
|
||||||
|
|
||||||
ARG VERSION
|
ARG VERSION
|
||||||
ENV VERSION=${VERSION}
|
ENV VERSION=${VERSION}
|
||||||
|
@ -29,13 +31,13 @@ ENV VERSION=${VERSION}
|
||||||
ARG MAKE_ARGS
|
ARG MAKE_ARGS
|
||||||
ENV MAKE_ARGS=${MAKE_ARGS}
|
ENV MAKE_ARGS=${MAKE_ARGS}
|
||||||
|
|
||||||
RUN --mount=type=cache,target="/go/pkg/mod" \
|
ENV GOCACHE=/root/.cache/go-build
|
||||||
--mount=type=cache,target="/root/.cache/go-build" \
|
ENV GOPATH=/root/go
|
||||||
make ${MAKE_ARGS} build link-binary && \
|
RUN make ${MAKE_ARGS} build link-binary && \
|
||||||
mv bin /app/ && \
|
mv bin /app/ && \
|
||||||
mkdir -p /app/error_pages /app/certs
|
mkdir -p /app/error_pages /app/certs
|
||||||
|
|
||||||
# Stage 2: Final image
|
# Stage 3: Final image
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
|
||||||
LABEL maintainer="yusing@6uo.me"
|
LABEL maintainer="yusing@6uo.me"
|
||||||
|
|
Loading…
Add table
Reference in a new issue