add ARG CONTRY=CN to improve the alpinelinux install speed

This commit is contained in:
Tao Chen
2024-11-01 00:29:33 +08:00
parent 503e908eb6
commit d21b5809c4
2 changed files with 16 additions and 2 deletions

View File

@@ -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/

View File

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