Repository navigation
Docker improvements - #3042
Docker improvements#3042
Conversation
- Changed from alpine to python:slim - Removed some database libs (because we *connect* to a db, not host it)
- Only create inventree user as part of production build (leave admin access for dev build)
|
@SchrodingersGat these numbers look much better. Do you think we could get under 500 MBs? That is the magical number for a lot of included private docker registries. |
|
I think that 500MB would be an ambitious target, not sure what else we can trim at this point! |
|
@SchrodingersGat have you tried the python-alpine image? It seems to be only 90MB. I just tried - It does not help. |
- As we have mounted volumes at 'run time' we need to ensure that the inventree user has correct permissions! - Ref: https://stackoverflow.com/questions/39397548/how-to-give-non-root-user-in-docker-container-access-to-a-volume-mounted-on-the
- Only drop to non-root user as part of "production" build - Mounted external volumes make it tricky when in the dev build - Might want to revisit this later on
- reduce required system packages -
|
@matmair any idea why the sqlite coverage checks are failing here? Nominally I have not changed any internal code or tests, only the docker image, but the test is not running under docker... Edit: It is because I have updated the weasyprint version, and your wonderful unit tests have thrown an error ⭐ |
|
@matmair reasonable. I'll leave the CI stuff how it is. |
# Conflicts: # .github/workflows/qc_checks.yaml
- Directory / path issues
- Directory / path issues
|
@matmair I think this is getting pretty close now - LMK what you think. I would like to get this merged in before thinking about signing the docker image in a different PR |
matmair
left a comment
There was a problem hiding this comment.
@SchrodingersGat there are a few open questions form my side - especially moving the dockerfile and removing deploy info.
|
|
||
| on: | ||
| release: | ||
| types: [published] |
| uses: ./.github/actions/setup | ||
| with: | ||
| apt-dependency: gettext | ||
| apt-dependency: gettext poppler-utils |
There was a problem hiding this comment.
should we mabybe add this requirement to the docs?
There was a problem hiding this comment.
Great point - I'll add this to inventree/inventree-docs#295
| @@ -1,21 +0,0 @@ | |||
| # Checks version number | |||
| name: version number | |||
| @@ -49,82 +50,82 @@ LABEL org.label-schema.schema-version="1.0" \ | |||
| org.label-schema.vendor="inventree" \ | |||
| org.label-schema.name="inventree/inventree" \ | |||
| org.label-schema.url="https://hub.docker.com/r/inventree/inventree" \ | |||
| org.label-schema.vcs-url=${INVENTREE_GIT_REPO} \ | |||
| org.label-schema.vcs-branch=${INVENTREE_GIT_BRANCH} \ | |||
| org.label-schema.vcs-ref=${INVENTREE_GIT_TAG} | |||
There was a problem hiding this comment.
The git commit information is now passed through to the docker image at build time - the "production" image does not contain the .git directory any longer
There was a problem hiding this comment.
The tags are exposed if the image is up - right? A user once told me that he uses the image labels for kubernetes automation.
| """Test that the git commit information is extracted successfully""" | ||
|
|
||
| envs = { |
There was a problem hiding this comment.
Suggestion: To conform with google docstyle there eshould be no newline here
| INVENTREE_LOG_LEVEL=WARNING | ||
|
|
||
| # InvenTree admin account details | ||
| # Un-comment (and complete) these lines to auto-create an admin acount |
There was a problem hiding this comment.
Leaving unused passwords in the env can be dangerous - should we maybe also add a note about this?
Suggestion:
Remove the entered credentials after the first run
| flake8-docstrings==1.6.0 # docstring format testing | ||
| gunicorn>=20.1.0 # Gunicorn web server | ||
| importlib_metadata # Backport for importlib.metadata | ||
| inventree # Install the latest version of the InvenTree API python library |
There was a problem hiding this comment.
Any idea why that was in here in the first place? Seems to be a non-dependency for deployment enviroments
There was a problem hiding this comment.
I think it crept in during my testing and never got removed. No real reason to have it here at all.
There was a problem hiding this comment.
I am currently looking into pip-tools and using full dependency pinning - that might be more stable for testing and deployment. The secondary dependencies could vary the way we do it now.
|
|
||
| # Install required Python packages with PIP | ||
| c.run('pip3 install -U -r requirements.txt') | ||
| c.run('pip3 install --no-cache-dir --disable-pip-version-check -U -r requirements.txt') |
There was a problem hiding this comment.
Question: Won't --no-cache-dir increase the download traffic a lot?
There was a problem hiding this comment.
Hmm not sure about that. Might be worth checking. My understanding was that it reduced the final docker image size
There was a problem hiding this comment.
Did not know that - always learning new stuff! Then I think this is the right step 👍
| # This directory specified where InvenTree source code is stored "outside" the docker containers | ||
| # By default, this directory is one level above the "docker" directory | ||
| device: ${INVENTREE_EXT_VOLUME:-../} | ||
| device: ${INVENTREE_EXT_VOLUME:-./} |
There was a problem hiding this comment.
Question: Any specific reason for the move?
There was a problem hiding this comment.
Yep. Previously the docker build was performed from within the ./docker directory, and involved re-downloading the source code from git based on the specified tag. However as we are now building from the github workflow, we have already defined the context of the built image (latest / stable / tag) and so we can use the simpler process of copying source files into the image.
However this needs to be performed from the top-level directory as you cannot COPY files from a directory above
There was a problem hiding this comment.
Seems more efficient, I like it!
| @@ -1,46 +0,0 @@ | |||
| ; # Supervisor Config File | |||
There was a problem hiding this comment.
Question: Why is this removed? I am pretty sure we are linking to this in the docs for bare metal installs
There was a problem hiding this comment.
Ah you're right. I did a cursory search and thought it was orphaned.. I'll add it back in.
Also check .j2k files
|
@matmair thanks for the review. Have made a few changes as suggested |
@SchrodingersGat great changes! Should be fine now in my view. |
|
@matmair regarding the build time / image size with 185s / 989MB without 115s / 1.04GB I'd say the hit to image size is worth it, given the major reduction in build time |
Experimenting with changing docker image base from alpine to python:slim
Also trying to remove requirement for cairo, and update to latest version of weasyprint.
Weasyprint updates
Changing to a
python:slimbase docker image has seemingly fixed the issues which were preventing an update to django-weasyprint - ref #2456 .Image Comparison
232s151sTODO
.gitdirectory)