0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-11-19 22:24:29 +01:00

avoid copying all files to trim down the build stage

This commit is contained in:
TheFox0x7 2025-10-11 13:56:26 +02:00
parent 2421538677
commit 2f9e04745d
No known key found for this signature in database
GPG Key ID: 6CA33903484AF7C2
2 changed files with 48 additions and 10 deletions

View File

@ -17,6 +17,8 @@ RUN apk --no-cache add \
WORKDIR ${GOPATH}/src/code.gitea.io/gitea
COPY Makefile .
# Fetch go dependencies
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
@ -27,16 +29,33 @@ COPY package.json pnpm-lock.yaml ./
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile --prod
# Setup repo
COPY . ${GOPATH}/src/code.gitea.io/gitea
COPY ./webpack.config.ts tailwind.config.ts ./
COPY ./assets ./assets
COPY ./public ./public
COPY ./web_src ./web_src
RUN make frontend
# Copy source files
COPY ./build ./build
COPY ./cmd ./cmd
COPY ./models ./models
COPY ./modules ./modules
COPY ./options ./options
COPY ./routers ./routers
COPY ./services ./services
COPY ./templates ./templates
COPY ./build.go .
COPY ./main.go .
COPY contrib/environment-to-ini/environment-to-ini.go contrib/environment-to-ini/environment-to-ini.go
COPY ./custom ./custom
# Checkout version if set
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
--mount=type=cache,target=/go/pkg/mod \
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target="/root/.cache/go-build" \
--mount=type=bind,source=".git",target="${GOPATH}/src/code.gitea.io/gitea/.git" \
if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
&& make build
&& make backend
# Begin env-to-ini build
RUN --mount=type=cache,target=/go/pkg/mod \

View File

@ -17,6 +17,8 @@ RUN apk --no-cache add \
WORKDIR ${GOPATH}/src/code.gitea.io/gitea
COPY Makefile .
# Fetch go dependencies
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
@ -27,16 +29,33 @@ COPY package.json pnpm-lock.yaml ./
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile --prod
# Setup repo
COPY . ${GOPATH}/src/code.gitea.io/gitea
COPY ./webpack.config.ts tailwind.config.ts ./
COPY ./assets ./assets
COPY ./public ./public
COPY ./web_src ./web_src
RUN make frontend
# Copy source files
COPY ./build ./build
COPY ./cmd ./cmd
COPY ./models ./models
COPY ./modules ./modules
COPY ./options ./options
COPY ./routers ./routers
COPY ./services ./services
COPY ./templates ./templates
COPY ./build.go .
COPY ./main.go .
COPY contrib/environment-to-ini/environment-to-ini.go contrib/environment-to-ini/environment-to-ini.go
COPY ./custom ./custom
# Checkout version if set
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
--mount=type=cache,target=/go/pkg/mod \
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target="/root/.cache/go-build" \
--mount=type=bind,source=".git",target="${GOPATH}/src/code.gitea.io/gitea/.git" \
if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
&& make build
&& make backend
# Begin env-to-ini build
RUN --mount=type=cache,target=/go/pkg/mod \