diff --git a/Dockerfile b/Dockerfile index 9c164aa..321807c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ diff --git a/contrib/roncarve/compose.production.yaml b/contrib/roncarve/compose.production.yaml index db7cb4d..2e5261e 100644 --- a/contrib/roncarve/compose.production.yaml +++ b/contrib/roncarve/compose.production.yaml @@ -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