Skip to content

Commit

Permalink
chore: Use poetry in Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
bennetrr committed Apr 10, 2024
1 parent 94bc7d2 commit 6cd0e67
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
FROM python:3.12-slim

# importing the action
COPY ["src", "/action"]
# Copy the action
COPY ["src", "poetry.lock", "pyproject.toml", "/action/"]

# installing the dependencies
RUN pip install -r /action/requirements.txt
# Install poetry
# Thanks to Soof Golan and jjmerelo from StackOverflow: https://stackoverflow.com/a/72465422
ARG POETRY_VERSION=1.8.2
ENV POETRY_VENV=/opt/poetry-venv
ENV POETRY_CACHE_DIR=/opt/.cache

# Create a venv and install Poetry there
RUN /usr/local/bin/python3.12 -m venv $POETRY_VENV
RUN $POETRY_VENV/bin/python -m pip install -U pip setuptools
RUN $POETRY_VENV/bin/python -m pip install poetry==${POETRY_VERSION}

# Add Poetry to the PATH
ENV PATH="${PATH}:${POETRY_VENV}/bin"

RUN poetry -C /action install --no-interaction --no-cache --without dev

# Print which git
RUN echo "which git: $(which git)"

# Install git
RUN apt-get -yq update && apt-get -yq install git && rm -rf /var/lib/apt/lists/*
RUN apt-get -yq update && \
apt-get -yq install git && \
rm -rf /var/lib/apt/lists/*

RUN chmod +x /action/entrypoint.sh

# Set the entrypoint
ENTRYPOINT ["/action/entrypoint.sh"]
ENTRYPOINT ["poetry", "-C", "/action", "run", "/action/entrypoint.sh"]

0 comments on commit 6cd0e67

Please sign in to comment.