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 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
# Build stage
|
# 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
|
# Use Aliyun mirrors for faster package downloads in China
|
||||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
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
|
RUN cargo build --release
|
||||||
|
|
||||||
# Runtime stage
|
# Runtime stage
|
||||||
FROM alpine:3.21
|
FROM ${DOCKER_MIRROR}alpine:3.21
|
||||||
|
|
||||||
# Use Aliyun mirrors
|
# Use Aliyun mirrors
|
||||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./backend_rust
|
context: ./backend_rust
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
DOCKER_MIRROR: ${DOCKER_MIRROR:-}
|
||||||
container_name: notify-backend
|
container_name: notify-backend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
@@ -23,6 +25,7 @@ services:
|
|||||||
context: ./frontend
|
context: ./frontend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
args:
|
args:
|
||||||
|
DOCKER_MIRROR: ${DOCKER_MIRROR:-}
|
||||||
NEXT_PUBLIC_API_BASE: ${NEXT_PUBLIC_API_BASE:-http://localhost}
|
NEXT_PUBLIC_API_BASE: ${NEXT_PUBLIC_API_BASE:-http://localhost}
|
||||||
container_name: notify-frontend
|
container_name: notify-frontend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# Build stage
|
# 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
|
# Use Aliyun mirrors for Alpine packages
|
||||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
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
|
RUN npm run build
|
||||||
|
|
||||||
# Production stage
|
# Production stage
|
||||||
FROM node:20-alpine AS runner
|
FROM ${DOCKER_MIRROR}node:20-alpine AS runner
|
||||||
|
|
||||||
# Use Aliyun mirrors for Alpine packages
|
# Use Aliyun mirrors for Alpine packages
|
||||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||||
|
|||||||
Reference in New Issue
Block a user