Skip to content

Commit

Permalink
Build steps for Poetry virtualenv
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkafton committed Feb 1, 2024
1 parent a225a62 commit 60b864f
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,42 @@ 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_CACHE_DIR='/tmp/cache/poetry'
POETRY_VIRTUALENVS_CREATE=false \
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
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 apt-get clean && apt-get purge

USER mitodl

EXPOSE 8063
Expand Down

0 comments on commit 60b864f

Please sign in to comment.