Skip to content

Conversation

wilmardo
Copy link
Contributor

Somewhat of a simpler implementation of #3919

@theProf I cherry-picked some of your work to not discard your work :)

  • Moves the yarn build into the Dockerfile so that a simple docker build ends up as a working image instead of missing the compiled frontend
  • Moves the version.py executing into the CI so that the .git directory can be omitted from the container
  • Reduce the amount of files in the final image by just the bare minimum

@wilmardo wilmardo changed the title Optimize Dockerfile part2 Optimize Dockerfile and build process Sep 15, 2025
@wilmardo wilmardo closed this Sep 16, 2025
@wilmardo wilmardo reopened this Sep 16, 2025
@vabene1111
Copy link
Collaborator

thanks for this and the other PR's
I do have some feature updates I want to finish before playing with the setup again and I need to think about some preferences regarding this. Will get back to this but might be a bit, sorry.

@wilmardo
Copy link
Contributor Author

wilmardo commented Sep 17, 2025

No worries, let me know if there are any questions

also @theProf feel free to shoot some comments. I decided on less stages to keep the Dockerfile more simple and readable

Copy link

@edysli edysli left a comment

Choose a reason for hiding this comment

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

Thank you for the improvements @wilmardo 😃

Comment on lines +40 to +70
COPY --link requirements.txt ./

RUN <<EOF
# remove Development dependencies from requirements.txt
sed -i '/# Development/,$d' requirements.txt
apk add --no-cache --virtual .build-deps \
build-base \
cargo \
curl \
g++ \
gcc \
jpeg-dev \
libffi-dev \
libwebp-dev \
musl-dev \
postgresql-dev \
python3-dev \
openldap-dev \
openssl-dev \
xmlsec \
xmlsec-dev \
rust \
zlib-dev
python -m venv venv
venv/bin/python -m pip install --upgrade pip
venv/bin/pip debug -v
venv/bin/pip install wheel==0.45.1
venv/bin/pip install setuptools_rust==1.10.2
venv/bin/pip install -r requirements.txt --no-cache-dir
apk --purge del .build-deps
EOF
Copy link

@edysli edysli Oct 1, 2025

Choose a reason for hiding this comment

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

I suggest moving building the venv to a separate stage. This way we would have one stage for the frontend and its build dependencies, one stage for the backend and its build dependencies, and one final image with runtime dependencies.


RUN <<EOF
# remove Development dependencies from requirements.txt
sed -i '/# Development/,$d' requirements.txt
Copy link

Choose a reason for hiding this comment

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

Rather out of scope for this PR, but I think the Python dev dependencies should be moved to another file to cleanly separate them, for example in requirements_dev.txt.

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.

4 participants