Skip to content

Commit

Permalink
Update actions/setup-python to use pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysyngsun committed Feb 7, 2025
1 parent 14edda3 commit 224100b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: "3.12.1"
python-version-file: "pyproject.toml"
cache: "poetry"

- uses: actions/setup-node@v4
Expand Down
30 changes: 21 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.12
FROM python:3.12.1
LABEL maintainer "ODL DevOps <[email protected]>"

# Add package files, install updated node and pip
Expand All @@ -19,27 +19,39 @@ RUN mkdir /src
RUN adduser --disabled-password --gecos "" mitodl
RUN mkdir /var/media && chown -R mitodl:mitodl /var/media

# Poetry env configuration
## Set some poetry config
ENV \
# poetry:
POETRY_VERSION=1.5.1 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR='/tmp/cache/poetry'
POETRY_VERSION=1.7.1 \
POETRY_VIRTUALENVS_CREATE=true \
POETRY_CACHE_DIR='/tmp/cache/poetry' \
POETRY_HOME='/home/mitodl/.local' \
VIRTUAL_ENV="/opt/venv"
ENV PATH="$VIRTUAL_ENV/bin:$POETRY_HOME/bin:$PATH"

# Install poetry
RUN pip install "poetry==$POETRY_VERSION"

# Install project packages
COPY pyproject.toml /src
COPY poetry.lock /src
COPY mitol_django_*.gz /src
RUN chown -R mitodl:mitodl /src
RUN mkdir ${VIRTUAL_ENV} && chown -R mitodl:mitodl ${VIRTUAL_ENV}

## Install poetry itself, and pre-create a venv with predictable name
USER mitodl
RUN curl -sSL https://install.python-poetry.org \
| \
POETRY_VERSION=${POETRY_VERSION} \
POETRY_HOME=${POETRY_HOME} \
python3 -q
WORKDIR /src
RUN python3 -m venv $VIRTUAL_ENV
RUN poetry install

# Add project
USER root
COPY . /src
WORKDIR /src
RUN chown -R mitodl:mitodl /src
RUN mkdir /src/staticfiles

USER mitodl

Expand Down
26 changes: 4 additions & 22 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = ["MIT ODL"]


[tool.poetry.dependencies]
python = "^3.11.0"
python = "3.12.1"
attrs = "^23.1.0"
base36 = "^0.1.1"
beautifulsoup4 = "^4.12.0"
Expand Down

0 comments on commit 224100b

Please sign in to comment.