The previous attempt to upgrade RALibretro before a new tagged version
was available (#1970) needed to be reverted, as the RAHasher tool failed
with segmentation faults in some scenarios.
Bump `RALibretro` to the latest commit from the upstream repository.
Removes the need to use an older version of Alpine Linux, but requires
some changes to the `RALibretro` source code to compile successfully.
The `nginx` image is still not available for Alpine 3.22, but we can
also upgrade to its latest patch version (`1.27.5`).
As the container entrypoint runs `envsubst` to replace environment
variables in the nginx configuration files, the `/etc/nginx/conf.d` and
its contents must be writable by everyone.
This is needed because a user can set a custom UID/GID to run the
container, and the `envsubst` command will run as that user.
Using the `envsubst` command, we can replace environment variables in
the nginx template files. This allows for more flexibility when
configuring the nginx server.
The Docker image we use as base for Nginx does provide the
`20-envsubst-on-templates.sh` script that will replace environment
variables in the template files.
This change does not include any behavior change, but unblocks future
changes that require environment variables in the nginx configuration.
This change removes the installation of `dev` and `test` Poetry
dependency groups from the published Docker images.
Developers are still able to use images with development dependencies
installed, by either using the `dev-slim` or `dev-full` targets.
Image size comparison:
* `slim-image`: Down from 455 MiB to 355 MiB.
* `full-image`: Down from 760 MiB to 660 MiB.
This change only verifies that Alembic can upgrade and downgrade through
all the current migrations. It does not verify that the application
works correctly with PostgreSQL.
This commit improves Docker layer caching by installing the required
packages in the `production-stage` stage, before copying files from
other stages.
This way, dependency installation will remain cached unless there's a
change in the required `apk` packages (or the stage's base image).
`tini` does not wait for child processes to close, so all processes will be killed immediately. This is why the container stops so fast.
This fix makes the `init` script listen and handle terminate signals. It also ensures that child processes are shut down in reverse order with proper waiting for completion.
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/
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
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
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
```