build(docker): support configurable package mirrors
giteabot backport / giteabot (push) Canceled after 0s
release-nightly / nightly-binary (push) Canceled after 0s
release-nightly / nightly-container (push) Canceled after 0s
giteabot / giteabot (push) Canceled after 0s
release-nightly-snapcraft / build-and-publish (push) Canceled after 0s

Assisted-by: Codex:GPT-5
This commit is contained in:
2026-08-16 08:30:25 +08:00
parent 2bd534fd5e
commit d951144f98
2 changed files with 19 additions and 4 deletions
+15 -4
View File
@@ -1,10 +1,15 @@
# syntax=docker/dockerfile:1
# Build frontend on the native platform to avoid QEMU-related issues with nodejs ecosystem
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.26-alpine3.24 AS frontend-build
RUN apk --no-cache add build-base git nodejs pnpm
ARG ALPINE_MIRROR=""
ARG NPM_REGISTRY=""
RUN if [ -n "$ALPINE_MIRROR" ]; then sed -i "s|https://dl-cdn.alpinelinux.org/alpine|$ALPINE_MIRROR|g" /etc/apk/repositories; fi && \
apk --no-cache add build-base git nodejs pnpm
WORKDIR /src
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN --mount=type=cache,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
if [ -n "$NPM_REGISTRY" ]; then pnpm config set registry "$NPM_REGISTRY"; fi && \
pnpm install --frozen-lockfile
COPY --exclude=.git/ . .
RUN make frontend
@@ -15,9 +20,13 @@ ARG GITEA_VERSION
ARG TAGS=""
ENV TAGS="bindata timetzdata $TAGS"
ARG CGO_EXTRA_CFLAGS
ARG ALPINE_MIRROR=""
ARG GOPROXY=https://proxy.golang.org,direct
ENV GOPROXY=$GOPROXY
# Build deps
RUN apk --no-cache add \
RUN if [ -n "$ALPINE_MIRROR" ]; then sed -i "s|https://dl-cdn.alpinelinux.org/alpine|$ALPINE_MIRROR|g" /etc/apk/repositories; fi && \
apk --no-cache add \
build-base \
git
@@ -48,7 +57,9 @@ FROM docker.io/library/alpine:3.24 AS gitea
EXPOSE 22 3000
RUN apk --no-cache add \
ARG ALPINE_MIRROR=""
RUN if [ -n "$ALPINE_MIRROR" ]; then sed -i "s|https://dl-cdn.alpinelinux.org/alpine|$ALPINE_MIRROR|g" /etc/apk/repositories; fi && \
apk --no-cache add \
bash \
ca-certificates \
curl \
+4
View File
@@ -3,6 +3,10 @@ services:
build:
context: ../..
dockerfile: Dockerfile
args:
ALPINE_MIRROR: https://mirrors.aliyun.com/alpine
GOPROXY: https://goproxy.cn,direct
NPM_REGISTRY: https://registry.npmmirror.com
image: roncarve/gita:1.27.2-production
container_name: gitea
hostname: git.roncarve.com