用于构建 Django Web 应用的 Docker 镜像:
FROM python:3.10.12-bullseye
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
# 安装依赖 和阿里云源
RUN echo "deb http://mirrors.aliyun.com/debian/ bullseye main" > /etc/apt/sources.list \
&& echo "deb-src http://mirrors.aliyun.com/debian/ bullseye main" >> /etc/apt/sources.list \
&& apt-get update && apt-get install -y \
libldap2-dev \
libsasl2-dev
# RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
# RUN pip install -r requirements.txt --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple
COPY . /code/
# port where the Django app runs
EXPOSE 8000
# start server
CMD bash start.sh
# CMD python manage.py runserver 0.0.0.0:8000