Skip to content

Commit 86dc3b0

Browse files
committed
update dockerfile
1 parent 9ae9114 commit 86dc3b0

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

.github/workflows/docker-image.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
uses: docker/build-push-action@v5
2525
with:
2626
push: true
27-
tags: botalovserg/test-docker:latest
27+
tags: botalovserg/app-bot-docker:latest

Dockerfile

+28-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,33 @@
1-
FROM python:3.11-slim-bullseye
1+
FROM python:3.10 as python-base
2+
3+
# https://python-poetry.org/docs#ci-recommendations
4+
ENV POETRY_VERSION=1.8.3
5+
ENV POETRY_HOME=/opt/poetry
6+
ENV POETRY_VENV=/opt/poetry-venv
7+
8+
# Tell Poetry where to place its cache and virtual environment
9+
ENV POETRY_CACHE_DIR=/opt/.cache
10+
11+
# Create stage for Poetry installation
12+
FROM python-base as poetry-base
13+
14+
# Creating a virtual environment just for poetry and install it with pip
15+
RUN python3 -m venv $POETRY_VENV \
16+
&& $POETRY_VENV/bin/pip install -U pip setuptools \
17+
&& $POETRY_VENV/bin/pip install poetry==${POETRY_VERSION}
18+
19+
# Create a new stage from the base python image
20+
FROM python:3.11-slim-bullseye as bot-app
21+
COPY --from=poetry-base ${POETRY_VENV} ${POETRY_VENV}
222
ENV PYTHONDONTWRITEBYTECODE 1
323
ENV PYTHONUNBUFFERED 1
424
WORKDIR /app
5-
COPY requirements.txt .
6-
RUN pip install --no-cache -r /app/requirements.txt
25+
# Copy Dependencies
26+
COPY poetry.lock pyproject.toml ./
27+
28+
# [OPTIONAL] Validate the project is properly configured
29+
RUN poetry check
30+
# Install Dependencies
31+
RUN poetry install --no-interaction --no-cache --without dev
732
COPY . /app
833
CMD ["python3", "main.py"]

0 commit comments

Comments
 (0)