# 使用基础的 Python 镜像作为基础
FROM python:3.8
# 设置工作目录
WORKDIR /mydjpro
# 将项目的依赖项添加到容器中
COPY requirements.txt /mydjpro/
RUN pip install urllib3
RUN apt-get update && apt-get install -y libmariadb-dev-compat
RUN pip install mysqlclient
RUN python3 -m pip install pytz
RUN pip install --no-cache-dir --ignore-installed --no-deps -r requirements.txt
COPY . /mydjpro/
# 等待数据库启动
RUN sleep 10
#RUN python manage.py migrate
# 运行 Django 项目
RUN python manage.py collectstatic
CMD python manage.py runserver 0:8888
ALLOWED_HOSTS = ['10.10.32.8', '0.0.0.0', '127.0.0.1']
DEBUG = False
git clone 仓库地址
docker build -t integratedtestmanagement:tag .
其中8888是容器内部的端口号,8886是对外开放的端口号
docker run -p 8886:8888 integratedtestmanagement:tag