chore: 优化 dockerfile,缩小镜像体积

This commit is contained in:
amtoaer
2024-01-06 01:43:16 +08:00
parent 345c764463
commit 641cc3f48b

View File

@@ -1,4 +1,4 @@
FROM python:3.11.7-alpine3.19
FROM python:3.11.7-alpine3.19 as base
WORKDIR /app
@@ -6,17 +6,19 @@ ENV LANG=zh_CN.UTF-8 \
TZ=Asia/Shanghai \
BILI_IN_DOCKER=true
COPY poetry.lock pyproject.toml ./
RUN apk add --no-cache ffmpeg tini \
&& apk add --no-cache --virtual .build-deps \
gcc \
musl-dev \
libffi-dev \
openssl-dev \
&& pip install poetry \
&& poetry config virtualenvs.create false \
&& pip install poetry==1.7.1 pip3-autoremove==1.2.0
COPY poetry.lock pyproject.toml ./
RUN poetry config virtualenvs.create false \
&& poetry install --only main --no-root \
&& pip3-autoremove -y poetry pip3-autoremove \
&& apk del .build-deps \
&& rm -rf \
/root/.cache \
@@ -24,6 +26,16 @@ RUN apk add --no-cache ffmpeg tini \
COPY . .
FROM scratch
WORKDIR /app
ENV LANG=zh_CN.UTF-8 \
TZ=Asia/Shanghai \
BILI_IN_DOCKER=true
COPY --from=base / /
ENTRYPOINT [ "tini", "python", "entry.py" ]
VOLUME [ "/app/config", "/app/data", "/app/thumb", "/Videos/Bilibilis" ]