Configuration files for creating a sample containerized environment for a Rails API application
We must separate all software requirements from the local system while also sharing a folder with the application between the virtual and local systems.
Additionally, the application should run with non-root privileges inside its container.
Perhaps it would be better to make one image, but there are already redy to use compact ones. Custom image tends to bloat significantly. Also, in a production database separated from an application; it would be not bad to mimic this in development.
- Versions are not pinned neither for gems nor for pacages in the 'web'.
- No IDE integration checked.
- All gems installation could be moved to the 'Dockerfile' perhaps, but database setup have to be done after its starts obviously
Edit run_rails.sh
accordingly to your requirements. Containers app dir will be in the '/app' folder.
To change its name from the api_project
to the prefered, change it in Dockerfile
and `podman-compose.yml'.
Run:
podman-compose --pod-args '--userns keep-id' up --build-arg USERNAME=$(id -un) --build-arg GROUPNAME=$(id -gn) --build-arg USERID=$(id -u) --build-arg GROUPID=$(id -g)
If there is no rails application in current directory, it will be created. Username and user id of the app files owner inside the container will be the same as a local user. All gems will be installed to user's home dir in the container.
Get a shell inside the container:
podman exec -it <container name> /bin/sh
Shutdown
podman-compose down
see containers/podman#18580 containers/podman-compose#654 esp. containers/podman-compose#654 (comment)