From f34c01afdfe2fff7ccfc6f99eef242527bfb7ba7 Mon Sep 17 00:00:00 2001 From: Michael Dong Date: Wed, 11 Feb 2026 13:44:04 +0800 Subject: [PATCH] Add configurable Docker mirror for China network builds Add DOCKER_MIRROR build arg to Dockerfiles so base images can be pulled through a mirror registry (e.g. docker.1ms.run/) when Docker Hub is unreachable. Defaults to empty (direct Docker Hub). Co-Authored-By: Claude Opus 4.6 --- backend_rust/Dockerfile | 5 +++-- docker-compose.deploy.yml | 3 +++ frontend/Dockerfile | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/backend_rust/Dockerfile b/backend_rust/Dockerfile index c4137f8..8ab0088 100644 --- a/backend_rust/Dockerfile +++ b/backend_rust/Dockerfile @@ -1,5 +1,6 @@ # Build stage -FROM rust:1.85-alpine AS builder +ARG DOCKER_MIRROR="" +FROM ${DOCKER_MIRROR}rust:1.85-alpine AS builder # Use Aliyun mirrors for faster package downloads in China RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories @@ -40,7 +41,7 @@ RUN touch src/main.rs migration/src/main.rs migration/src/lib.rs RUN cargo build --release # Runtime stage -FROM alpine:3.21 +FROM ${DOCKER_MIRROR}alpine:3.21 # Use Aliyun mirrors RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories diff --git a/docker-compose.deploy.yml b/docker-compose.deploy.yml index 8c855e1..1818b07 100644 --- a/docker-compose.deploy.yml +++ b/docker-compose.deploy.yml @@ -5,6 +5,8 @@ services: build: context: ./backend_rust dockerfile: Dockerfile + args: + DOCKER_MIRROR: ${DOCKER_MIRROR:-} container_name: notify-backend restart: unless-stopped extra_hosts: @@ -23,6 +25,7 @@ services: context: ./frontend dockerfile: Dockerfile args: + DOCKER_MIRROR: ${DOCKER_MIRROR:-} NEXT_PUBLIC_API_BASE: ${NEXT_PUBLIC_API_BASE:-http://localhost} container_name: notify-frontend restart: unless-stopped diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 89ef128..18bebe6 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,5 +1,6 @@ # Build stage -FROM node:20-alpine AS builder +ARG DOCKER_MIRROR="" +FROM ${DOCKER_MIRROR}node:20-alpine AS builder # Use Aliyun mirrors for Alpine packages RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories @@ -29,7 +30,7 @@ RUN mkdir -p public RUN npm run build # Production stage -FROM node:20-alpine AS runner +FROM ${DOCKER_MIRROR}node:20-alpine AS runner # Use Aliyun mirrors for Alpine packages RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories