Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile optimization. #414

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 28 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
FROM python:3.8-slim
FROM python:3.8-slim as dependencies

RUN \
set -eux; \
apt-get update; \
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
python3-pip \
build-essential \
python3-venv \
ffmpeg \
git \
; \
rm -rf /var/lib/apt/lists/*
ENV PYTHONFAULTHANDLER=1
ENV PYTHONUNBUFFERED=1
ENV PYTHONHASHSEED=random
ENV PYTHONDONTWRITEBYTECODE 1
ENV PIP_NO_CACHE_DIR=off
ENV PIP_DISABLE_PIP_VERSION_CHECK=on
ENV PIP_DEFAULT_TIMEOUT=100

RUN pip3 install -U pip && pip3 install -U wheel && pip3 install -U setuptools==59.5.0
COPY ./requirements.txt /tmp/requirements.txt
RUN pip3 install -r /tmp/requirements.txt && rm -r /tmp/requirements.txt
RUN apt-get update && \
apt-get install -y build-essential

COPY . /code
WORKDIR /code

CMD ["bash"]
COPY requirements.txt /
WORKDIR /dependencies

RUN pip3 install --target=/dependencies -r /requirements.txt


FROM python:3.8-slim as final

ENV PYTHONFAULTHANDLER=1
ENV PYTHONUNBUFFERED=1
ENV PYTHONHASHSEED=random
ENV PYTHONPATH="${PYTHONPATH}:/dependencies"

WORKDIR /app

COPY --from=dependencies /dependencies /dependencies
COPY . .

ENTRYPOINT ["python3", "bot/bot.py"]
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ services:

chatgpt_telegram_bot:
container_name: chatgpt_telegram_bot
command: python3 bot/bot.py
restart: always
build:
context: "."
Expand Down