- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.2k
Add comments for speeding up installations in China #379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -8,6 +8,8 @@ FROM node:20-alpine3.22 AS node_base | |
| FROM node_base AS node_deps | ||
| WORKDIR /app | ||
| COPY package.json package-lock.json ./ | ||
| # ** use this instead for speeding up, if in China | ||
| # RUN npm ci --legacy-peer-deps --registry=https://registry.npmmirror.com | ||
| RUN npm ci --legacy-peer-deps | ||
|  | ||
| FROM node_base AS node_builder | ||
|  | @@ -27,6 +29,8 @@ WORKDIR /app | |
| RUN python -m venv /opt/venv | ||
| ENV PATH="/opt/venv/bin:$PATH" | ||
| COPY api/requirements.txt ./api/ | ||
| # ** use this instead for speeding up, if in China | ||
| RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ --no-cache -r api/requirements.txt | ||
| RUN pip install --no-cache -r api/requirements.txt | ||
| 
      Comment on lines
    
      +32
     to 
      34
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change introduces a second  A better approach is to use a build argument for the PyPI mirror. This makes the Dockerfile cleaner, more maintainable, and avoids the redundant command. The   | ||
|  | ||
| # Use Python 3.11 as final image | ||
|  | @@ -36,6 +40,10 @@ FROM python:3.11-slim | |
| WORKDIR /app | ||
|  | ||
| # Install Node.js and npm | ||
|  | ||
| # ** use this instead for speeding up, if in China | ||
| # RUN sed -i 's@deb.debian.org@mirrors.aliyun.com@g' /etc/apt/sources.list.d/debian.sources \ | ||
| # && apt-get update && apt-get install -y \ | ||
| RUN apt-get update && apt-get install -y \ | ||
| 
      Comment on lines
    
      +44
     to 
      47
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the   | ||
| curl \ | ||
| gnupg \ | ||
|  | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While adding a commented-out alternative is helpful, a more robust and cleaner approach for handling alternative package registries is to use build arguments. This avoids having commented-out code in the Dockerfile and makes it easier for users to switch registries without editing the file. The
ifstatement ensures the default behavior is preserved if no mirror is specified.