Skip to content

Commit fb324af

Browse files
committed
Add mount cache for docker building
1 parent 04783f5 commit fb324af

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

Dockerfile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ ARG TAGS="sqlite sqlite_unlock_notify"
99
ENV TAGS="bindata timetzdata $TAGS"
1010
ARG CGO_EXTRA_CFLAGS
1111

12+
ARG GOCACHE
13+
ENV GOCACHE=${GOCACHE:-/root/.cache/go-build}
14+
15+
ARG GOMODCACHE
16+
ENV GOMODCACHE=${GOMODCACHE:-/go/pkg/mod}
17+
1218
# Build deps
1319
RUN apk --no-cache add \
1420
build-base \
@@ -23,10 +29,17 @@ WORKDIR ${GOPATH}/src/code.gitea.io/gitea
2329

2430
# Checkout version if set
2531
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
26-
&& make clean-all build
32+
&& make clean-all
33+
34+
RUN --mount=type=cache,target=/root/.npm \
35+
--mount=type=cache,target=/go/pkg/mod/ \
36+
--mount=type=cache,target="/root/.cache/go-build" \
37+
make build
2738

2839
# Begin env-to-ini build
29-
RUN go build contrib/environment-to-ini/environment-to-ini.go
40+
RUN --mount=type=cache,target=/go/pkg/mod/ \
41+
--mount=type=cache,target="/root/.cache/go-build" \
42+
go build contrib/environment-to-ini/environment-to-ini.go
3043

3144
# Copy local files
3245
COPY docker/root /tmp/local

Dockerfile.rootless

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ ARG TAGS="sqlite sqlite_unlock_notify"
99
ENV TAGS="bindata timetzdata $TAGS"
1010
ARG CGO_EXTRA_CFLAGS
1111

12+
ARG GOCACHE
13+
ENV GOCACHE=${GOCACHE:-/root/.cache/go-build}
14+
15+
ARG GOMODCACHE
16+
ENV GOMODCACHE=${GOMODCACHE:-/go/pkg/mod}
17+
1218
#Build deps
1319
RUN apk --no-cache add \
1420
build-base \
@@ -23,10 +29,17 @@ WORKDIR ${GOPATH}/src/code.gitea.io/gitea
2329

2430
# Checkout version if set
2531
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
26-
&& make clean-all build
32+
&& make clean-all
33+
34+
RUN --mount=type=cache,target=/root/.npm \
35+
--mount=type=cache,target=/go/pkg/mod/ \
36+
--mount=type=cache,target="/root/.cache/go-build" \
37+
make build
2738

2839
# Begin env-to-ini build
29-
RUN go build contrib/environment-to-ini/environment-to-ini.go
40+
RUN --mount=type=cache,target=/go/pkg/mod/ \
41+
--mount=type=cache,target="/root/.cache/go-build" \
42+
go build contrib/environment-to-ini/environment-to-ini.go
3043

3144
# Copy local files
3245
COPY docker/rootless /tmp/local

0 commit comments

Comments
 (0)