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

exclude git from container build

It's not required and grows over time.
Also exclude containerfiles from the copy so changes in them won't
trigger layer invalidation if it's not needed
This commit is contained in:
TheFox0x7 2025-10-23 20:39:10 +02:00
parent 1218db2867
commit 1aa245f372
No known key found for this signature in database
GPG Key ID: 6CA33903484AF7C2
3 changed files with 12 additions and 71 deletions

View File

@ -74,7 +74,8 @@ cpu.out
/VERSION
/.air
/.go-licenses
Dockerfile
Dockerfile.rootless
# Files and folders that were previously generated
/public/assets/img/webpack

View File

@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1
# Build stage
FROM docker.io/library/golang:1.25-alpine3.22 AS build-env
@ -16,46 +17,15 @@ RUN apk --no-cache add \
pnpm
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 \
go mod download
# Fetch pnpm dependencies
COPY package.json pnpm-lock.yaml ./
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile --prod
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
COPY --exclude=.git/ . .
# Checkout version if set
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" \
--mount=type=cache,target=/root/.local/share/pnpm/store \
--mount=type=bind,source=".git/",target=".git/" \
if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
&& make backend
&& make
# Begin env-to-ini build
RUN --mount=type=cache,target=/go/pkg/mod \

View File

@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1
# Build stage
FROM docker.io/library/golang:1.25-alpine3.22 AS build-env
@ -16,46 +17,15 @@ RUN apk --no-cache add \
pnpm
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 \
go mod download
# Fetch pnpm dependencies
COPY package.json pnpm-lock.yaml ./
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile --prod
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
COPY --exclude=.git/ . .
# Checkout version if set
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" \
--mount=type=cache,target=/root/.local/share/pnpm/store \
--mount=type=bind,source=".git/",target=".git/" \
if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
&& make backend
&& make
# Begin env-to-ini build
RUN --mount=type=cache,target=/go/pkg/mod \