From d21b5809c4b28b7ce139eac325398fbc8fe86abb Mon Sep 17 00:00:00 2001 From: Tao Chen Date: Fri, 1 Nov 2024 00:29:33 +0800 Subject: [PATCH] add ARG CONTRY=CN to improve the alpinelinux install speed --- Dockerfile.dev | 16 ++++++++++++++-- docker-compose-dev.yaml | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Dockerfile.dev b/Dockerfile.dev index 43aa840..741f98e 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -32,7 +32,13 @@ FROM node:18-alpine AS builder-admin-frontend # Set working directory WORKDIR /frontend -RUN apk update && apk add git --no-cache +ARG COUNTRY +# Install required tools without caching index to minimize image size +RUN if [ "$COUNTRY" = "CN" ] ; then \ + echo "It is in China, updating the repositories"; \ + sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirrors.tuna.tsinghua.edu.cn/alpine#g' /etc/apk/repositories; \ + fi && \ + apk update && apk add --no-cache git # Clone the frontend repository RUN git clone https://github.com/lejianwen/rustdesk-api-web . @@ -47,7 +53,13 @@ FROM alpine:latest WORKDIR /app # Install necessary runtime dependencies -RUN apk add --no-cache tzdata file +# Install required tools without caching index to minimize image size +ARG COUNTRY +RUN if [ "$COUNTRY" = "CN" ] ; then \ + echo "It is in China, updating the repositories"; \ + sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirrors.tuna.tsinghua.edu.cn/alpine#g' /etc/apk/repositories; \ + fi && \ + apk update && apk add --no-cache tzdata file # Copy the built application and resources from the builder stage COPY --from=builder-backend /app/release /app/ diff --git a/docker-compose-dev.yaml b/docker-compose-dev.yaml index d015bc1..9e30042 100644 --- a/docker-compose-dev.yaml +++ b/docker-compose-dev.yaml @@ -3,6 +3,8 @@ services: build: context: . dockerfile: Dockerfile.dev + args: + COUNTRY: CN # image: lejianwen/rustdesk-api container_name: rustdesk-api environment: