0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-11-20 04:53:30 +01:00

Add mount cache for docker building

This commit is contained in:
Lunny Xiao 2025-06-26 17:30:34 -07:00 committed by TheFox0x7
parent c5332fdc55
commit 062c5f45d0
No known key found for this signature in database
GPG Key ID: 6CA33903484AF7C2
2 changed files with 30 additions and 4 deletions

View File

@ -9,6 +9,12 @@ ARG TAGS="sqlite sqlite_unlock_notify"
ENV TAGS="bindata timetzdata $TAGS"
ARG CGO_EXTRA_CFLAGS
ARG GOCACHE
ENV GOCACHE=${GOCACHE:-/root/.cache/go-build}
ARG GOMODCACHE
ENV GOMODCACHE=${GOMODCACHE:-/go/pkg/mod}
# Build deps
RUN apk --no-cache add \
build-base \
@ -24,10 +30,17 @@ WORKDIR ${GOPATH}/src/code.gitea.io/gitea
# Checkout version if set
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
&& make clean-all build
&& make clean-all
RUN --mount=type=cache,target=/root/.npm \
--mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target="/root/.cache/go-build" \
make build
# Begin env-to-ini build
RUN go build contrib/environment-to-ini/environment-to-ini.go
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target="/root/.cache/go-build" \
go build contrib/environment-to-ini/environment-to-ini.go
# Copy local files
COPY docker/root /tmp/local

View File

@ -9,6 +9,12 @@ ARG TAGS="sqlite sqlite_unlock_notify"
ENV TAGS="bindata timetzdata $TAGS"
ARG CGO_EXTRA_CFLAGS
ARG GOCACHE
ENV GOCACHE=${GOCACHE:-/root/.cache/go-build}
ARG GOMODCACHE
ENV GOMODCACHE=${GOMODCACHE:-/go/pkg/mod}
#Build deps
RUN apk --no-cache add \
build-base \
@ -24,10 +30,17 @@ WORKDIR ${GOPATH}/src/code.gitea.io/gitea
# Checkout version if set
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
&& make clean-all build
&& make clean-all
RUN --mount=type=cache,target=/root/.npm \
--mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target="/root/.cache/go-build" \
make build
# Begin env-to-ini build
RUN go build contrib/environment-to-ini/environment-to-ini.go
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target="/root/.cache/go-build" \
go build contrib/environment-to-ini/environment-to-ini.go
# Copy local files
COPY docker/rootless /tmp/local