-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathDockerfile
More file actions
30 lines (24 loc) · 928 Bytes
/
Dockerfile
File metadata and controls
30 lines (24 loc) · 928 Bytes
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
# ---- 运行环境 ----
FROM python:3.11-alpine AS running
ENV LANG='en_US.UTF-8' \
LANGUAGE='en_US.UTF-8' \
TZ='Asia/Shanghai' \
GUNICORN_WORKERS=2 \
PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
RUN \
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
&& apk --update -t --no-cache add tzdata libpq \
&& ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime \
&& echo "${TZ}" > /etc/timezone \
&& apk add --no-cache --virtual .build-deps gcc python3-dev musl-dev postgresql-dev \
&& pip install --upgrade pip \
&& pip install --no-cache-dir psycopg2-binary \
&& apk del --no-cache .build-deps
WORKDIR /app
# 下载依赖
COPY requirements.txt .
RUN --mount=type=cache,id=pip,target=/root/.cache \
pip install -r requirements.txt
# 拷贝代码
COPY . .
CMD ["sh", "-c", "exec gunicorn -w ${GUNICORN_WORKERS} -b 0.0.0.0:8000 app.main:app"]