-
Notifications
You must be signed in to change notification settings - Fork 0
Dockerfile uses poetry in development and no venv in production #3
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
base: main
Are you sure you want to change the base?
Conversation
4c9e747
to
bcccc95
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, couple minor comments which you can take or leave. I will give it a spin later and approve.
ENV PYTHONUNBUFFERED=1 | ||
|
||
# Extend the socket timeout. Default would be 15s | ||
ENV PIP_DEFAULT_TIMEOUT=100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ENV PIP_DEFAULT_TIMEOUT=100 | |
ENV PIP_DEFAULT_TIMEOUT=100 |
# RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \ | ||
# vim-tiny |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be removed? Or do we want to add a comment explaining this is how to add packages if you need them?
# RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \ | ||
# wget\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove?
|
||
# Setting this to 'off' actually turns off the cache. This is set to decrease | ||
# the size of the image. | ||
ENV PIP_NO_CACHE_DIR=off |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ENV PIP_NO_CACHE_DIR=off | |
ENV PIP_NO_CACHE_DIR=off |
ENV PIP_NO_CACHE_DIR=off | ||
|
||
# Speed up pip usage by not checking for the version | ||
ENV PIP_DISABLE_PIP_VERSION_CHECK=on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ENV PIP_DISABLE_PIP_VERSION_CHECK=on | |
ENV PIP_DISABLE_PIP_VERSION_CHECK=on |
COPY pyproject.toml poetry.lock README.md ./ | ||
# Ensure that the virtual environment directory is in the project. This path | ||
# will be be `/app/.venv/` | ||
ENV POETRY_VIRTUALENVS_IN_PROJECT=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ENV POETRY_VIRTUALENVS_IN_PROJECT=1 | |
ENV POETRY_VIRTUALENVS_IN_PROJECT=1 |
# Set up our final runtime layer | ||
FROM python:3.11-slim-bookworm as runtime | ||
# Create the virtual environment if it does not already exist | ||
ENV POETRY_VIRTUALENVS_CREATE=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ENV POETRY_VIRTUALENVS_CREATE=1 | |
ENV POETRY_VIRTUALENVS_CREATE=1 |
* Changes Docker structure so that there is poetry in the development step, and pip in the production step * Cleands up the documentation in the dockerfile * Adds some directories and filenames to .gitignore and .dockerignore * init.sh has shellcheck improvements and installs python packages
bcccc95
to
b9eca9d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked for me!
Dockerfile now has poetry in the
development
stage, meaning one can install packages with poetry in the container, and one does not have to have poetry installed locally.The
production
stage runspip install
on therequirements.txt
generated by poetry in thebuild
stage.The
init.sh
script hasshellcheck
improvements, and adds installing poetry packages.