add: Docker Support

This commit is contained in:
raiots 2022-01-30 13:16:15 +08:00
parent c6e965b38a
commit 6a46184fda
2 changed files with 27 additions and 0 deletions

17
Dockerfile Normal file
View File

@ -0,0 +1,17 @@
# 从仓库拉取 带有 python 3.7 的 Linux 环境
FROM python:3.7
# 设置 python 环境变量
ENV PYTHONUNBUFFERED 1
# 创建 code 文件夹并将其设置为工作目录
RUN mkdir /code
WORKDIR /code
# 更新 pip
RUN pip install pip -U
# 将 requirements.txt 复制到容器的 code 目录
ADD requirements.txt /code/
# 安装库
RUN pip install -r requirements.txt -i https://mirrors.ustc.edu.cn/pypi/web/simple
# 将当前目录复制到容器的 code 目录
ADD . /code/

10
docker-compose.yml Normal file
View File

@ -0,0 +1,10 @@
version: "3"
services:
app:
restart: always
build: . # '点'代表当前目录
command: "python3 manage.py runserver 0.0.0.0:8000"
volumes:
- .:/code
ports:
- "8000:8001"