Skip to content

Reduce Docker container size#747

Merged
Donkie merged 3 commits into
Donkie:masterfrom
Shadowsith:745-docker-size-optimization
Jan 5, 2026
Merged

Reduce Docker container size#747
Donkie merged 3 commits into
Donkie:masterfrom
Shadowsith:745-docker-size-optimization

Conversation

@Shadowsith
Copy link
Copy Markdown
Contributor

@Shadowsith Shadowsith commented Aug 20, 2025

These changes optimize the size of the docker container based on #745

Before with python:3.12-bookwom: ~1.09 GB

After the changes: ~276 MB

How I've tested it:

  1. Installed client npm dependencies and built client in project with production api environment
  2. Created a docker-compose.yml in project root folder to build/test the local spoolman image
  3. Tested Dockerfile changes via docker-compose build
  4. Started container via docker-compose up -d and made some user tests within the web client

My local docker-compose.yml as reference

version: '3.8'
services:
  spoolman:
    image: spoolman
    container_name: spoolman
    restart: unless-stopped
    volumes:
      # Mount the host machine's ./data directory into the container's /home/app/.local/share/spoolman directory
      - ./data:/home/app/.local/share/spoolman
    ports:
      # Map the host machine's port 7912 to the container's port 8000
      - "7912:8000"
    environment:
      - TZ=Europe/Stockholm # Optional, defaults to UTC
    build:
      context: .
      target: python-runner
``

@Shadowsith Shadowsith changed the title Reduce docker container size by usage of slim bookworm #745 Reduce docker container size Aug 20, 2025
@Shadowsith Shadowsith changed the title Reduce docker container size Reduce Docker container size Aug 20, 2025
Comment thread Dockerfile Outdated
Comment thread Dockerfile Outdated
Comment on lines 46 to 60
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You've done great getting the docker image much smaller. You can get it a bit slimmer by moving this build to the builder stage and using COPY --from=python-builder to get just the resulting binary. This allows you to avoid curl, gcc, and libc-dev dependencies.

I'm seeing built image size of ~253MB with those changes. Not nearly the gain you already achieved but I'm more interested in avoiding having dev tools in my images.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

the dependencies are removed at the last line, apt-get purge

Comment thread Dockerfile
@@ -1,4 +1,4 @@
FROM python:3.12-bookworm AS python-builder
FROM python:3.12-slim-bookworm AS python-builder
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since this uses multi stage builds, I think you can use the non-slim image here. It won't affect the final image and includes some dependencies you might otherwise need.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think it's good practice to have the same base image in both the builder and runner, both so that they share the same base and dependencies, and it reduces the number of images you need to download

@Donkie
Copy link
Copy Markdown
Owner

Donkie commented Jan 5, 2026

I hijacked your PR a bit, but I've fixed some issues and minimized the final docker image as much as possible.
Thanks for the contribution, and sorry for the delay!

@Donkie Donkie merged commit 9124ce0 into Donkie:master Jan 5, 2026
renovate Bot added a commit to sdwilsh/ansible-playbooks that referenced this pull request Jan 23, 2026
##### [\`0.23.0\`](https://github.com/Donkie/Spoolman/releases/tag/v0.23.0)

New year new update!

Spoolman development has slowed down considerably last year, due to multiple personal reasons from my side. Here is an update with all the things that have accumulated over the last months. Most of the updates are from contributions from the community, many thanks!

There's been many significant dependency version updates in this update. Please report any new issues you find. If anything is breaking your ability to use it, it's safe to go back to the previous version (22.1) until it has been addressed.

##### What's Changed

- Improved standalone install script. It now automatically downloads and installs the best Python version for you. This means Spoolman should now support a lot more distributions, and you don't need to fix any Python versions or other packages beforehand!
- Spoolman docker images are now officially published on [dockerhub](https://hub.docker.com/r/donkieyo/spoolman)!
- Spoolman now uses uv instead of pdm for backend package management.
- Updated all backend and client packages to their latest versions.
- Spoolman now requires at least Python 3.10, and defaults to Python 3.14 in both Docker and Standalone installation methods.
- Added adjust spool button by [@htsachakis](https://github.com/htsachakis) in [#626](Donkie/Spoolman#626)
- 🔨 Add pool\_recycle for MySQL by [@sinclairpaul](https://github.com/sinclairpaul) in [#668](Donkie/Spoolman#668)
- Add Measured Weight option to the filament adjustment modal  by [@spyder007](https://github.com/spyder007) in [#660](Donkie/Spoolman#660)
- Remade translation into Brazilian Portuguese by [@opastorello](https://github.com/opastorello) in [#694](Donkie/Spoolman#694)
- Add SPOOLMAN\_CORS\_ORIGIN variable by [@ecarjat](https://github.com/ecarjat) in [#605](Donkie/Spoolman#605)
- Add Spoolcount in Locations Page by [@JakobGue](https://github.com/JakobGue) in [#715](Donkie/Spoolman#715)
- Fix Spool Edit page Empty Weight and Initial Weight bug by [@ajford](https://github.com/ajford) in [#717](Donkie/Spoolman#717)
- Reduce Docker container size by [@Shadowsith](https://github.com/Shadowsith) in [#747](Donkie/Spoolman#747)
- Supports PWA. by [@sixiaolong1117](https://github.com/sixiaolong1117) in [#762](Donkie/Spoolman#762)
- Add support for Fedora to install.sh by [@mnebelung](https://github.com/mnebelung) in [#786](Donkie/Spoolman#786)
- All caps short QR codes for alphanumerical encoding by [@beikeland](https://github.com/beikeland) in [#777](Donkie/Spoolman#777)
- Bugfix for issue [#803](Donkie/Spoolman#803) and [#805](Donkie/Spoolman#805) by [@kaufi95](https://github.com/kaufi95) in [#811](Donkie/Spoolman#811)

##### Translations

- Updated Norwegian Bokmål translation by Vegard Fladby
- Updated Lithuanian translation by vjurka
- Updated French translation by Bazzofski
- Updated Hindi (Latin script) translation by Archit Jain
- Updated Italian translation by Giadej
- Updated Czech translation by Miloslav Kos and Marek Dvorný
- Updated Russian translation by dimquea and Dr\_Perry\_Coke
- Updated Romanian translation by Cristian
- Updated Turkish translation by Yücelen Gül
- Updated Spanish translation by Jose
- Updated Portuguese (Brazil) translation by KnightArch
- Updated Portuguese translation by rupefelo
- Updated German translation by Tobias Maschek, derSchreiber, Justus Kagerer and Ivo Grossen
- Updated Tamil translation by தமிழ்நேரம்
- Updated Polish translation by Julia 🌸🏳️‍⚧️
- Updated Chinese (Simplified Han script) translation by Samuel Wang
- Updated Estonian translation by Arvi Saluste

##### New Contributors

- [@htsachakis](https://github.com/htsachakis) made their first contribution in [#626](Donkie/Spoolman#626)
- [@sinclairpaul](https://github.com/sinclairpaul) made their first contribution in [#668](Donkie/Spoolman#668)
- [@opastorello](https://github.com/opastorello) made their first contribution in [#694](Donkie/Spoolman#694)
- [@ecarjat](https://github.com/ecarjat) made their first contribution in [#605](Donkie/Spoolman#605)
- [@JakobGue](https://github.com/JakobGue) made their first contribution in [#715](Donkie/Spoolman#715)
- [@ajford](https://github.com/ajford) made their first contribution in [#717](Donkie/Spoolman#717)
- [@Shadowsith](https://github.com/Shadowsith) made their first contribution in [#747](Donkie/Spoolman#747)
- [@sixiaolong1117](https://github.com/sixiaolong1117) made their first contribution in [#762](Donkie/Spoolman#762)
- [@mnebelung](https://github.com/mnebelung) made their first contribution in [#786](Donkie/Spoolman#786)
- [@beikeland](https://github.com/beikeland) made their first contribution in [#777](Donkie/Spoolman#777)
- [@kaufi95](https://github.com/kaufi95) made their first contribution in [#811](Donkie/Spoolman#811)

**Full Changelog**: <Donkie/Spoolman@v0.22.1...v0.23.0>
sdwilsh pushed a commit to sdwilsh/ansible-playbooks that referenced this pull request Jan 29, 2026
##### [\`0.23.0\`](https://github.com/Donkie/Spoolman/releases/tag/v0.23.0)

New year new update!

Spoolman development has slowed down considerably last year, due to multiple personal reasons from my side. Here is an update with all the things that have accumulated over the last months. Most of the updates are from contributions from the community, many thanks!

There's been many significant dependency version updates in this update. Please report any new issues you find. If anything is breaking your ability to use it, it's safe to go back to the previous version (22.1) until it has been addressed.

##### What's Changed

- Improved standalone install script. It now automatically downloads and installs the best Python version for you. This means Spoolman should now support a lot more distributions, and you don't need to fix any Python versions or other packages beforehand!
- Spoolman docker images are now officially published on [dockerhub](https://hub.docker.com/r/donkieyo/spoolman)!
- Spoolman now uses uv instead of pdm for backend package management.
- Updated all backend and client packages to their latest versions.
- Spoolman now requires at least Python 3.10, and defaults to Python 3.14 in both Docker and Standalone installation methods.
- Added adjust spool button by [@htsachakis](https://github.com/htsachakis) in [#626](Donkie/Spoolman#626)
- 🔨 Add pool\_recycle for MySQL by [@sinclairpaul](https://github.com/sinclairpaul) in [#668](Donkie/Spoolman#668)
- Add Measured Weight option to the filament adjustment modal  by [@spyder007](https://github.com/spyder007) in [#660](Donkie/Spoolman#660)
- Remade translation into Brazilian Portuguese by [@opastorello](https://github.com/opastorello) in [#694](Donkie/Spoolman#694)
- Add SPOOLMAN\_CORS\_ORIGIN variable by [@ecarjat](https://github.com/ecarjat) in [#605](Donkie/Spoolman#605)
- Add Spoolcount in Locations Page by [@JakobGue](https://github.com/JakobGue) in [#715](Donkie/Spoolman#715)
- Fix Spool Edit page Empty Weight and Initial Weight bug by [@ajford](https://github.com/ajford) in [#717](Donkie/Spoolman#717)
- Reduce Docker container size by [@Shadowsith](https://github.com/Shadowsith) in [#747](Donkie/Spoolman#747)
- Supports PWA. by [@sixiaolong1117](https://github.com/sixiaolong1117) in [#762](Donkie/Spoolman#762)
- Add support for Fedora to install.sh by [@mnebelung](https://github.com/mnebelung) in [#786](Donkie/Spoolman#786)
- All caps short QR codes for alphanumerical encoding by [@beikeland](https://github.com/beikeland) in [#777](Donkie/Spoolman#777)
- Bugfix for issue [#803](Donkie/Spoolman#803) and [#805](Donkie/Spoolman#805) by [@kaufi95](https://github.com/kaufi95) in [#811](Donkie/Spoolman#811)

##### Translations

- Updated Norwegian Bokmål translation by Vegard Fladby
- Updated Lithuanian translation by vjurka
- Updated French translation by Bazzofski
- Updated Hindi (Latin script) translation by Archit Jain
- Updated Italian translation by Giadej
- Updated Czech translation by Miloslav Kos and Marek Dvorný
- Updated Russian translation by dimquea and Dr\_Perry\_Coke
- Updated Romanian translation by Cristian
- Updated Turkish translation by Yücelen Gül
- Updated Spanish translation by Jose
- Updated Portuguese (Brazil) translation by KnightArch
- Updated Portuguese translation by rupefelo
- Updated German translation by Tobias Maschek, derSchreiber, Justus Kagerer and Ivo Grossen
- Updated Tamil translation by தமிழ்நேரம்
- Updated Polish translation by Julia 🌸🏳️‍⚧️
- Updated Chinese (Simplified Han script) translation by Samuel Wang
- Updated Estonian translation by Arvi Saluste

##### New Contributors

- [@htsachakis](https://github.com/htsachakis) made their first contribution in [#626](Donkie/Spoolman#626)
- [@sinclairpaul](https://github.com/sinclairpaul) made their first contribution in [#668](Donkie/Spoolman#668)
- [@opastorello](https://github.com/opastorello) made their first contribution in [#694](Donkie/Spoolman#694)
- [@ecarjat](https://github.com/ecarjat) made their first contribution in [#605](Donkie/Spoolman#605)
- [@JakobGue](https://github.com/JakobGue) made their first contribution in [#715](Donkie/Spoolman#715)
- [@ajford](https://github.com/ajford) made their first contribution in [#717](Donkie/Spoolman#717)
- [@Shadowsith](https://github.com/Shadowsith) made their first contribution in [#747](Donkie/Spoolman#747)
- [@sixiaolong1117](https://github.com/sixiaolong1117) made their first contribution in [#762](Donkie/Spoolman#762)
- [@mnebelung](https://github.com/mnebelung) made their first contribution in [#786](Donkie/Spoolman#786)
- [@beikeland](https://github.com/beikeland) made their first contribution in [#777](Donkie/Spoolman#777)
- [@kaufi95](https://github.com/kaufi95) made their first contribution in [#811](Donkie/Spoolman#811)

**Full Changelog**: <Donkie/Spoolman@v0.22.1...v0.23.0>
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