Просмотр исходного кода

add ARG CONTRY=CN to improve the alpinelinux install speed

Tao Chen 1 год назад
Родитель
Сommit
d21b5809c4
2 измененных файлов с 16 добавлено и 2 удалено
  1. 14 2
      Dockerfile.dev
  2. 2 0
      docker-compose-dev.yaml

+ 14 - 2
Dockerfile.dev

@@ -32,7 +32,13 @@ FROM node:18-alpine AS builder-admin-frontend
32 32
 # Set working directory
33 33
 WORKDIR /frontend
34 34
 
35
-RUN apk update && apk add git --no-cache
35
+ARG COUNTRY
36
+# Install required tools without caching index to minimize image size
37
+RUN if [ "$COUNTRY" = "CN" ] ; then \
38
+        echo "It is in China, updating the repositories"; \
39
+        sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirrors.tuna.tsinghua.edu.cn/alpine#g' /etc/apk/repositories; \
40
+    fi && \
41
+    apk update && apk add --no-cache git
36 42
 
37 43
 # Clone the frontend repository
38 44
 RUN git clone https://github.com/lejianwen/rustdesk-api-web .
@@ -47,7 +53,13 @@ FROM alpine:latest
47 53
 WORKDIR /app
48 54
 
49 55
 # Install necessary runtime dependencies
50
-RUN apk add --no-cache tzdata file
56
+# Install required tools without caching index to minimize image size
57
+ARG COUNTRY
58
+RUN if [ "$COUNTRY" = "CN" ] ; then \
59
+        echo "It is in China, updating the repositories"; \
60
+        sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirrors.tuna.tsinghua.edu.cn/alpine#g' /etc/apk/repositories; \
61
+    fi && \
62
+    apk update && apk add --no-cache tzdata file
51 63
 
52 64
 # Copy the built application and resources from the builder stage
53 65
 COPY --from=builder-backend /app/release /app/

+ 2 - 0
docker-compose-dev.yaml

@@ -3,6 +3,8 @@ services:
3 3
     build: 
4 4
       context: .
5 5
       dockerfile: Dockerfile.dev
6
+      args:
7
+        COUNTRY: CN
6 8
     # image: lejianwen/rustdesk-api
7 9
     container_name: rustdesk-api
8 10
     environment: