-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
45 lines (30 loc) · 1 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
FROM python:3.11 as requirements-stage
WORKDIR /tmp
RUN curl -sSL https://install.python-poetry.org | python -
ENV PATH="${PATH}:/root/.local/bin"
COPY ./pyproject.toml ./poetry.lock* /tmp/
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes
FROM python:3.11-slim
# 设置时区
ENV TZ=Asia/Shanghai
# Gunicon 配置
COPY ./docker/start.sh /start.sh
RUN chmod +x /start.sh
COPY ./docker/gunicorn_conf.py /gunicorn_conf.py
# 安装 uvicorn, gunicorn
# https://www.uvicorn.org/#quickstart
RUN apt-get update \
&& apt-get install -y --no-install-recommends gcc \
&& pip install --no-cache-dir --upgrade "uvicorn[standard]" gunicorn \
&& apt-get purge -y --auto-remove \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Django
ENV APP_MODULE home.asgi:application
# 安装依赖
COPY --from=requirements-stage /tmp/requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
RUN rm requirements.txt
# 复制网站
COPY . .
CMD ["/start.sh"]