Dockerfile pip poetry 中国特供

5 min read
FROM python:3
WORKDIR /app
ARG POETRY_VERSION=1.2.2
RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
    sed -i 's/security.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
RUN mkdir -p ~/.pip && \
    echo "[global]" > ~/.pip/pip.conf && \
    echo "index-url = https://pypi.tuna.tsinghua.edu.cn/simple" >> ~/.pip/pip.conf

RUN apt-get update &&\
    curl -sL https://deb.nodesource.com/setup_16.x | bash - &&\
    apt-get install -y nodejs &&\
    pip3 install poetry

COPY package*.json ./
COPY pyproject.toml ./
COPY poetry.lock ./
# Install dependencies
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi
RUN poetry install && npm install
COPY . .
CMD ["npm", "run", "dev"]