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

misc: Simplify backend environment configuration in Docker image #947

Merged

Conversation

adamantike
Copy link
Collaborator

This change moves the virtualenv creation in the Dockerfile to a separate stage, to simplify isolating the process and reduce the need for uninstalling build dependencies.

The approach is similar to the one explained in [1]. It relies on building a virtualenv folder, and copying it in the final stage. Changing the PATH environment variable makes the virtualenv usable by default, without affecting the default Python installation.

Also, added Dockerfile arguments for Alpine, nginx, and Python versions, as some of them are reused, and also simplifies testing new versions.

An extra side effect is that the image size for the final stage is reduced from 315MB to 262MB.

[1] https://scribe.rip/@albertazzir/blazing-fast-python-docker-builds-with-poetry-a78a66f5aed0

This change moves the virtualenv creation in the `Dockerfile` to a
separate stage, to simplify isolating the process and reduce the need
for uninstalling build dependencies.

The approach is similar to the one explained in [1]. It relies on
building a virtualenv folder, and copying it in the final stage.
Changing the `PATH` environment variable makes the virtualenv usable by
default, without affecting the default Python installation.

Also, added Dockerfile arguments for Alpine, nginx, and Python versions,
as some of them are reused, and also simplifies testing new versions.

An extra side effect is that the image size for the final stage is
reduced from 315MB to 262MB.

[1] https://scribe.rip/@albertazzir/blazing-fast-python-docker-builds-with-poetry-a78a66f5aed0
Copy link
Member

@gantoine gantoine left a comment

Choose a reason for hiding this comment

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

this is dope! will build it on my server once i'm back home to test.

@@ -1,11 +1,33 @@
ARG ALPINE_VERSION=3.19
ARG NGINX_VERSION=1.27.0
ARG PYTHON_VERSION=3.11
Copy link
Member

Choose a reason for hiding this comment

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

👍🏼

docker/Dockerfile Show resolved Hide resolved
COPY --from=backend-build /src/.venv /src/.venv
# Fix virtualenv link to python binary
RUN ln -sf "$(which python)" /src/.venv/bin/python
ENV PATH="/src/.venv/bin:${PATH}"
Copy link
Member

Choose a reason for hiding this comment

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

👍🏼

docker/init_scripts/init Show resolved Hide resolved
@gantoine gantoine merged commit dca2a59 into rommapp:master Jun 23, 2024
2 checks passed
@adamantike adamantike deleted the misc/simplify-dockerfile-backend branch June 23, 2024 14:23
@zurdi15 zurdi15 mentioned this pull request Jul 19, 2024
spiceratops referenced this pull request in spiceratops/k8s-gitops Jul 23, 2024
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [rommapp/romm](https://togithub.com/rommapp/romm) | minor | `3.2.0` ->
`3.3.0` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>rommapp/romm (rommapp/romm)</summary>

### [`v3.3.0`](https://togithub.com/rommapp/romm/releases/tag/3.3.0)

[Compare
Source](https://togithub.com/rommapp/romm/compare/3.2.0...3.3.0)

#### What's Changed

- UI complete redesign by
[@&#8203;zurdi15](https://togithub.com/zurdi15) in
[https://github.com/rommapp/romm/pull/934](https://togithub.com/rommapp/romm/pull/934)
- Covers are now fetch in their 1080p version by
[@&#8203;zurdi15](https://togithub.com/zurdi15) in
[https://github.com/rommapp/romm/pull/934](https://togithub.com/rommapp/romm/pull/934)
- Now sibling roms can have different covers by
[@&#8203;zurdi15](https://togithub.com/zurdi15) in
[https://github.com/rommapp/romm/pull/934](https://togithub.com/rommapp/romm/pull/934)
- Screenshots are fetch in their big version by
[@&#8203;zurdi15](https://togithub.com/zurdi15) in
[https://github.com/rommapp/romm/pull/934](https://togithub.com/rommapp/romm/pull/934)
- Setup wizard added for new **RomM** installations by
[@&#8203;zurdi15](https://togithub.com/zurdi15) in
[https://github.com/rommapp/romm/pull/976](https://togithub.com/rommapp/romm/pull/976)
- Added collections by [@&#8203;zurdi15](https://togithub.com/zurdi15)
in
[https://github.com/rommapp/romm/pull/964](https://togithub.com/rommapp/romm/pull/964)
- Add favourites collection as special collection by
[@&#8203;zurdi15](https://togithub.com/zurdi15) in
[https://github.com/rommapp/romm/pull/977](https://togithub.com/rommapp/romm/pull/977)
- SteamGridDB integration. Roms and collections can be edited with a
SteamGridDB cover by [@&#8203;zurdi15](https://togithub.com/zurdi15) in
[https://github.com/rommapp/romm/pull/960](https://togithub.com/rommapp/romm/pull/960)
- Enhanced scan logs by [@&#8203;zurdi15](https://togithub.com/zurdi15)
in
[https://github.com/rommapp/romm/pull/965](https://togithub.com/rommapp/romm/pull/965)
- Select main sibling added for merged roms in gallery by
[@&#8203;zurdi15](https://togithub.com/zurdi15) in
[https://github.com/rommapp/romm/pull/963](https://togithub.com/rommapp/romm/pull/963)
- Allow users to edit their own profile by
[@&#8203;zurdi15](https://togithub.com/zurdi15) in
[https://github.com/rommapp/romm/pull/975](https://togithub.com/rommapp/romm/pull/975)
- Fixed firmware drawer permissions by
[@&#8203;zurdi15](https://togithub.com/zurdi15) in
[https://github.com/rommapp/romm/pull/956](https://togithub.com/rommapp/romm/pull/956)
- Added total filesize endpoint by
[@&#8203;adamantike](https://togithub.com/adamantike) in
[https://github.com/rommapp/romm/pull/969](https://togithub.com/rommapp/romm/pull/969)
- Improved Docker image size by
[@&#8203;adamantike](https://togithub.com/adamantike) in
[https://github.com/rommapp/romm/pull/947](https://togithub.com/rommapp/romm/pull/947)
- Install redis instead of building in Dockerfile by
[@&#8203;gantoine](https://togithub.com/gantoine) in
[https://github.com/rommapp/romm/pull/945](https://togithub.com/rommapp/romm/pull/945)
- Fix section links and improve grammar/spelling in README.md by
[@&#8203;TylerVigario](https://togithub.com/TylerVigario) in
[https://github.com/rommapp/romm/pull/914](https://togithub.com/rommapp/romm/pull/914)
- Add trunk.io checks by
[@&#8203;gantoine](https://togithub.com/gantoine) in
[https://github.com/rommapp/romm/pull/868](https://togithub.com/rommapp/romm/pull/868)
- Add parallel-n64 to cores by
[@&#8203;gantoine](https://togithub.com/gantoine) in
[https://github.com/rommapp/romm/pull/923](https://togithub.com/rommapp/romm/pull/923)
- Use core icon when showing version by
[@&#8203;gantoine](https://togithub.com/gantoine) in
[https://github.com/rommapp/romm/pull/922](https://togithub.com/rommapp/romm/pull/922)
- Add interactive table of contents by
[@&#8203;Nicmorris1820](https://togithub.com/Nicmorris1820) in
[https://github.com/rommapp/romm/pull/924](https://togithub.com/rommapp/romm/pull/924)
- Added linuxserver/mariadb as alternative by
[@&#8203;need4swede](https://togithub.com/need4swede) in
[https://github.com/rommapp/romm/pull/926](https://togithub.com/rommapp/romm/pull/926)
- Added large carousel on screnshot click by
[@&#8203;zurdi15](https://togithub.com/zurdi15) in
[https://github.com/rommapp/romm/pull/932](https://togithub.com/rommapp/romm/pull/932)
- Resources structure migrated from
`resources/{platform_slug}/{rom_name}` to
`resources/roms/{platform_id}/{rom_id}`.
- Disabled zip compression on streaming multi-file download to increase
speed by [@&#8203;adamantike](https://togithub.com/adamantike) in
[https://github.com/rommapp/romm/pull/983](https://togithub.com/rommapp/romm/pull/983)
- Prevent mass-purging of roms during scan if filesystem is not
correctly mounted by [@&#8203;gantoine](https://togithub.com/gantoine)
in
[https://github.com/rommapp/romm/pull/987](https://togithub.com/rommapp/romm/pull/987)
- Fixed abort scan by [@&#8203;gantoine](https://togithub.com/gantoine)
in
[https://github.com/rommapp/romm/pull/1004](https://togithub.com/rommapp/romm/pull/1004)
- Added support for any kind of image extension on custom covers by
[@&#8203;gantoine](https://togithub.com/gantoine) in
[https://github.com/rommapp/romm/pull/1002](https://togithub.com/rommapp/romm/pull/1002)
-   Fixes and improvements everywhere

#### New Contributors

- [@&#8203;adamantike](https://togithub.com/adamantike) made their first
contribution in
[https://github.com/rommapp/romm/pull/947](https://togithub.com/rommapp/romm/pull/947)
- [@&#8203;TylerVigario](https://togithub.com/TylerVigario) made their
first contribution in
[https://github.com/rommapp/romm/pull/914](https://togithub.com/rommapp/romm/pull/914)
- [@&#8203;Nicmorris1820](https://togithub.com/Nicmorris1820) made their
first contribution in
[https://github.com/rommapp/romm/pull/924](https://togithub.com/rommapp/romm/pull/924)
- [@&#8203;need4swede](https://togithub.com/need4swede) made their first
contribution in
[https://github.com/rommapp/romm/pull/926](https://togithub.com/rommapp/romm/pull/926)
- [@&#8203;lepture](https://togithub.com/lepture) made their first
contribution in
[https://github.com/rommapp/romm/pull/931](https://togithub.com/rommapp/romm/pull/931)

**Full Changelog**:
rommapp/romm@3.2.0...3.3.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzQuMiIsInVwZGF0ZWRJblZlciI6IjM3LjQzNC4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL21pbm9yIl19-->
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.

2 participants