Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - Dockerfile Update to Install Python-Modules from local_requirements.txt #109

Merged
merged 4 commits into from
Mar 24, 2021

Conversation

jifox
Copy link
Contributor

@jifox jifox commented Mar 7, 2021

This feature implements the installation of additional python modules during invoke build if the file local_requirements.txt exists in project-directory.

@@ -42,4 +42,8 @@ COPY . /opt/nautobot

RUN poetry install

# Install additional requirements from local_requirements.txt
RUN if [ -f local_requirements.txt ] ; then cat local_requirements.txt | grep -E '^[^# ]' | cut -d= -f1 | xargs -n 1 poetry add ; fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, this is kind of clever, but not sure what this buys us in a container compared to just running if [ -f local_requirements.txt ] ; then pip install -r local_requirements.txt; fi.

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It at least has the small advantage that it stays within the Poetry tool chain instead of mixing Poetry and Pip. I'd want to test this to make sure it doesn't end up modifying the pyproject.toml/poetry.lock in Git, though?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glennmatthews Yeah that was my concern, too, I think. I just didn't spell it out. Pretty sure it would update them which might result in breaking layer caching.

@jifox
Copy link
Contributor Author

jifox commented Mar 9, 2021

I dont think that there can be a changes in source directory during a docker build because no volumes are mounted and the source directory will be copied to container image before executing the installations.

COPY pyproject.toml poetry.lock /opt/nautobot/
WORKDIR /opt/nautobot

RUN poetry install --no-root

COPY . /opt/nautobot

RUN poetry install

@jifox jifox closed this Mar 21, 2021
@jifox jifox reopened this Mar 22, 2021
@jathanism jathanism merged commit b2efaa6 into nautobot:develop Mar 24, 2021
@jathanism
Copy link
Contributor

Thanks @jifox ! 🙃

@jifox jifox deleted the feature_local_requirements branch March 24, 2021 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants