Alex Papanicolaou
02/23/2023, 5:33 PM├── Dockerfile
├── poetry.lock
├── pyproject.toml
└── src
└── pipelines
├── __init__.py
├── example_wf.py
└── another_example_wf.py
Dockerfile
that builds the image with package installed.
####################################################
# Wheel stage: build the wheel
####################################################
FROM python:$PYTHON_VERSION-slim-buster AS wheel
ARG WORKING_DIR="/root"
ENV PATH="/root/.local/bin:${PATH}"
RUN pip install pipx && \
pipx install poetry==$POETRY_VERSION && \
pipx ensurepath
ENV VENV /opt/venv
# Virtual environment
RUN python -m venv ${VENV}
ENV PATH="${VENV}/bin:$PATH"
WORKDIR $WORKING_DIR
# Copy the actual code
COPY . .
RUN poetry export -f requirements.txt -o requirements.txt --without-hashes && \
poetry build --format=wheel -vvv && \
mkdir -p /export && \
mv dist/*.whl requirements.txt /export
####################################################
# Final stage: an image with the package installed
####################################################
FROM python-base AS final
COPY --from=wheel /export/requirements.txt .
RUN pip install -r requirements.txt
COPY --from=wheel /export/*.whl .
RUN pip install $(echo *.whl) --constraint requirements.txt
# This tag is supplied by the build script and will be used to determine the version
# when registering tasks, workflows, and launch plans
ARG TAG
ENV FLYTE_INTERNAL_IMAGE $TAG
Yee
Alex Papanicolaou
02/24/2023, 3:55 AMdestionationDirectory
, and then put destionationDirectory
at the head of PYTHONPATH
so the import would supersede the module on the image on execution of the task code.Yee
Alex Papanicolaou
02/24/2023, 4:47 AMYou can have pythonpath just set in the docker image.Good point. if the dir is empty in the base image unless there’s a hot load, then I should get the behavior I want.
# Prepending the fast-registration destination directory so that if code is hot loaded
# for fast registration, the hot loaded code will supersede the installed module
ENV PYTHONPATH="/root:$PYTHONPATH"