Commit Graph

74 Commits

Author SHA1 Message Date
Michael Manganiello
9997b69ff6 feat: Add support for _FILE suffix in environment variables
This change allows setting environment variables with a `_FILE` suffix,
which will be used to load the contents of the file specified in the
variable into the variable without the suffix.

For example, setting `ROMM_AUTH_SECRET_KEY_FILE=/run/secrets/romm_auth_secret_key`
and creating a file with the secret key at the specified path will set
`ROMM_AUTH_SECRET_KEY` to the contents of the file.

A common use case for this is to use secrets in Docker Compose [1], to
avoid exposing secrets in the `docker-compose.yml` or `env` files.

[1] https://docs.docker.com/compose/how-tos/use-secrets/
2024-12-08 20:05:06 -03:00
Michael Manganiello
477d9b1744 feat: Add streaming support for 7zip hashing
At the moment, 7zip files are generating memory issues and even OOM
errors on user installations. This is because the current stable release
of `py7zr` does not support decompression streaming, and RomM needs to
decompress the each 7zip file in the library into memory to be able to
calculate hashes.

This change introduces a `py7zr` fork I created to have a stable commit
SHA to refer to in case upstream gets any forced pushes. It includes the
contents of the pull request the `py7zr` creator is working on to
support decompression streaming [1].

The way decompression streaming is implemented in `py7zr` is different
than the other compression utilities. Instead of being able to provide a
`bytes` iterator, we need to provide a `Py7zIO` implementation that
will call a callback on each read and write operation.

[1] https://github.com/miurahr/py7zr/pull/620
2024-11-08 21:31:11 -03:00
Michael Manganiello
26dcefa9f0 misc: Use tini as container entrypoint
Use tini [1] as the container entrypoint to ensure that the container
process is properly reaped when the container is stopped.

This is needed as the main container command is a shell script.

A simple way to test this change is to:

1. Build the container image and run it using `docker compose up`.
2. Within the same terminal, stop the container using `Ctrl+C`.
3. Verify that the container is properly stopped right away.

Without `tini`, the container takes a few seconds to stop, and it makes
one CPU core to be used at 100% during that time.

[1] https://github.com/krallin/tini
2024-10-30 09:15:02 -03:00
Michael Manganiello
b59411ccb7 misc: Upgrade RALibretro to v1.8.0 2024-10-11 22:45:05 -03:00
Michael Manganiello
cf3932f14a Merge pull request #1206 from rommapp/feat/add-rahasher
feat: Add RAHasher and util to calculate RetroAchievements hashes
2024-09-23 08:09:03 -03:00
Michael Manganiello
a82489a9c4 feat: Add RAHasher and util to calculate RetroAchievements hashes
Build and include the `RAHasher` binary in the Docker image, to
calculate hashes for RetroAchievements. Also, add a service to
run `RAHasher` from Python.

Example usage:

```python
from adapters.services.rahasher import RAHasherError, RAHasherService

rahasher = RAHasherService()
try:
    hash = await rahasher.calculate_hash("nes", Path("path/to/rom.nes"))
except RAHasherError:
    # Handle error
    hash = None
```
2024-09-22 23:40:25 -03:00
Michael Manganiello
66e5939b2b misc: Use bundled Valkey instead of Redis server
This change replaces the bundled Redis server with Valkey. No breaking
changes are introduced, as considered environment variables still
maintain the `REDIS_` prefix.

Fixes #925.
2024-09-22 13:27:18 -03:00
Michael Manganiello
0680063ebc misc: Add comments to Dockerfile about mod_zip 2024-08-21 00:08:25 -03:00
Michael Manganiello
0fad8ac282 feat: Use nginx mod_zip to generate multi-file zip downloads
This change installs and configures the `mod_zip` nginx module [1],
which allows nginx to stream ZIP files directly.

It includes a workaround needed to correctly calculate CRC-32 values for
included files, by including a new `server` section listening at port
8081, only used for the file requests to be upstream subrequests that
correctly trigger the CRC-32 calculation logic.

Also, to be able to provide a `m3u` file generated on the fly, we add a
`/decode` endpoint fully implemented in nginx using NJS, which receives
a `value` URL param, and decodes it using base64. The decoded value is
returned as the response.

That way, the contents of the `m3u` file is base64-encoded, and set as
part of the response, for `mod_zip` to include it in the ZIP file.

[1] https://github.com/evanmiller/mod_zip
2024-08-20 22:39:33 -03:00
Michael Manganiello
0c3afc0ebc misc: Pin Node version to v20
Avoid the stack being automatically upgraded to a new Node version, when
a different LTS is released.
2024-08-16 10:18:03 -03:00
Michael Manganiello
0fdbbe4625 misc: Upgrade Python to v3.12 and Alpine to v3.20
Included upgrades:
* Python: v3.12
* Alpine: v3.20 (which uses Python 3.12)
* nginx: v1.27.1
2024-08-15 20:14:32 -03:00
Georges-Antoine Assi
896d48108b Merge branch 'master' into calc-file-hashes-roms 2024-08-11 19:08:25 -04:00
Georges-Antoine Assi
5529b76952 start work on ruffle flash emulator 2024-07-29 20:55:06 -04:00
Georges-Antoine Assi
9386ca9e4a changes from self-review 2024-07-27 16:31:32 -04:00
Georges-Antoine Assi
ecc021e824 Merge branch 'master' into calc-file-hashes-roms 2024-07-27 12:17:18 -04:00
Zurdi
4872141de1 fixed scrappers assets on build 2024-07-08 16:30:23 +02:00
Michael Manganiello
7611e57811 misc: Fix FromAsCasing warning during Docker build
Fix recently introduced `FromAsCasing` [1] Docker build check.

[1] https://docs.docker.com/reference/build-checks/from-as-casing/
2024-07-06 20:37:41 -03:00
Zurdi
7c39d211fb fixed dockerfile for arm64 2024-07-06 23:59:52 +02:00
Georges-Antoine Assi
0546cee67d Merge branch 'master' into fix/improve-docker-layer-caching-on-frontend-changes 2024-06-23 10:24:02 -04:00
Michael Manganiello
32ef612b0a fix: Improve Docker layer caching on frontend changes
Avoid any changes in the `frontend/` folder to trigger `npm install`.
Instead, split the copies to have separate steps for install and build.
2024-06-22 20:29:52 -03:00
Michael Manganiello
0daa708a05 misc: Simplify backend environment configuration in Docker image
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
2024-06-22 18:19:16 -03:00
Georges-Antoine Assi
b16c58e4bb update redis build and update nginx 2024-06-21 13:03:50 -04:00
Georges-Antoine Assi
896cb57420 Install redis instead of building it 2024-06-21 12:48:42 -04:00
Georges-Antoine Assi
381f13e4b9 more tweaking 2024-05-31 18:30:42 -04:00
Georges-Antoine Assi
0efbd9f113 label final stage 2024-05-31 18:11:17 -04:00
Georges-Antoine Assi
ed68c01fe2 ask chatgpt 2024-05-31 18:05:13 -04:00
Georges-Antoine Assi
bae407a40d running as non-root user 2024-03-27 01:22:51 +00:00
Georges-Antoine Assi
369ab47736 get rid of logs volume 2024-03-25 17:30:38 -04:00
Georges-Antoine Assi
41d0d2eb46 more dir creating up in dockerfile + add redis password 2024-03-25 15:30:27 +00:00
Georges-Antoine Assi
49bafe5ab0 just set it to 777 2024-03-25 04:18:02 +00:00
Georges-Antoine Assi
c8dc872a0d remove from init script and use user docker attr 2024-03-24 23:23:10 -04:00
Georges-Antoine Assi
be553d5524 add shadow to set ownership 2024-03-18 02:53:27 +00:00
Georges-Antoine Assi
faaa81995c fix building image 2024-03-18 02:06:07 +00:00
Georges-Antoine Assi
d073657365 Allow setting dynamic PUID/PGID 2024-03-17 19:56:25 -04:00
Georges-Antoine Assi
e024fc987f bind redis data volume 2024-03-12 02:07:31 +00:00
Georges-Antoine Assi
558a1d0a8d add comments to redis in dockerfile 2024-03-06 10:01:08 -05:00
Georges-Antoine Assi
a36d49979e [WIP] build redis into container
expose port right
2024-03-01 10:36:02 -05:00
Georges-Antoine Assi
7ff61b6fe5 tweak docekrfile 2024-02-07 04:50:06 +00:00
Georges-Antoine Assi
ec5fe09d90 fix some build issues 2024-02-06 23:33:28 -05:00
Georges-Antoine Assi
eb18388a81 Mega refactor of asset 2024-02-01 17:59:06 -05:00
Georges-Antoine Assi
f3d44aae41 api endpoint for raw asset access 2024-01-18 09:48:57 -05:00
Georges-Antoine Assi
bd245cec4a Change urls to specify webrcade 2023-12-28 13:02:00 -05:00
Georges-Antoine Assi
4b97e21f46 Merge branch 'master' into webrcade-feed 2023-12-27 19:34:58 -05:00
Zurdi
25aab268e9 added pipx to dockerfile 2023-12-13 17:17:57 +01:00
Zurdi
4155632988 fixed build workflow installing poetry with pipx 2023-12-13 16:24:34 +01:00
Zurdi
0c51585fc6 adapted workflows to poetry_npm 2023-12-13 15:40:51 +01:00
Lukas Wingerberg
adf8127295 refactor init script and add error handling via watchdog loop 2023-10-31 22:39:08 +01:00
zurdi
7001511e26 fix - romm user added to nginx config and dockerfile 2023-10-25 01:33:45 +02:00
Lukas Wingerberg
8b9d174ef7 add libffi to fix arm64 builds and reorder packages alphabetically 2023-10-24 23:11:10 +02:00
Lukas Wingerberg
6fe4562d3d Move docker labels into git workflow 2023-10-24 22:55:53 +02:00