Skip to content

Commit

Permalink
chore: 优化 dockerfile,缩小镜像体积
Browse files Browse the repository at this point in the history
  • Loading branch information
amtoaer committed Jan 5, 2024
1 parent 345c764 commit 641cc3f
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
FROM python:3.11.7-alpine3.19
FROM python:3.11.7-alpine3.19 as base

WORKDIR /app

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 \
/tmp/*

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" ]

0 comments on commit 641cc3f

Please sign in to comment.