Skip to content

Add mount cache for docker building #34876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -23,10 +29,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
Expand Down
17 changes: 15 additions & 2 deletions Dockerfile.rootless
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -23,10 +29,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
Expand Down