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
|
||||
FROM golang:1.24.0-alpine AS builder
|
||||
# Stage 1: deps
|
||||
FROM golang:1.24.0-alpine AS deps
|
||||
HEALTHCHECK NONE
|
||||
|
||||
# package version does not matter
|
||||
|
@ -11,17 +11,19 @@ WORKDIR /src
|
|||
# Only copy go.mod and go.sum initially for better caching
|
||||
COPY go.mod go.sum /src/
|
||||
|
||||
# Utilize build cache
|
||||
RUN --mount=type=cache,target="/go/pkg/mod" \
|
||||
go mod download -x
|
||||
ENV GOPATH=/root/go
|
||||
RUN go mod download -x
|
||||
|
||||
ENV GOCACHE=/root/.cache/go-build
|
||||
# Stage 2: builder
|
||||
FROM deps AS builder
|
||||
|
||||
COPY Makefile /src/
|
||||
COPY cmd /src/cmd
|
||||
COPY internal /src/internal
|
||||
COPY pkg /src/pkg
|
||||
COPY agent /src/agent
|
||||
WORKDIR /src
|
||||
|
||||
COPY Makefile ./
|
||||
COPY cmd ./cmd
|
||||
COPY internal ./internal
|
||||
COPY pkg ./pkg
|
||||
COPY agent ./agent
|
||||
|
||||
ARG VERSION
|
||||
ENV VERSION=${VERSION}
|
||||
|
@ -29,13 +31,13 @@ ENV VERSION=${VERSION}
|
|||
ARG MAKE_ARGS
|
||||
ENV MAKE_ARGS=${MAKE_ARGS}
|
||||
|
||||
RUN --mount=type=cache,target="/go/pkg/mod" \
|
||||
--mount=type=cache,target="/root/.cache/go-build" \
|
||||
make ${MAKE_ARGS} build link-binary && \
|
||||
ENV GOCACHE=/root/.cache/go-build
|
||||
ENV GOPATH=/root/go
|
||||
RUN make ${MAKE_ARGS} build link-binary && \
|
||||
mv bin /app/ && \
|
||||
mkdir -p /app/error_pages /app/certs
|
||||
|
||||
# Stage 2: Final image
|
||||
# Stage 3: Final image
|
||||
FROM scratch
|
||||
|
||||
LABEL maintainer="yusing@6uo.me"
|
||||
|
|
Loading…
Add table
Reference in a new issue