This app demonstrates Rails 7 with PostgreSQL, import maps, turbo, stimulus, bootstrap and hotwire, all running in Docker.
You can also bootstrap the application with authentication frameworks like Devise in order to ease your work.
- Rails 7
- Ruby 3
- Bootstrap
- Dockerfile and Docker Compose configuration
- PostgreSQL database
- Redis
- GitHub Actions for
- tests
- Rubocop for linting
- Security checks with Brakeman and bundler-audit
- Dependabot for automated updates
- Authentication with Devise
- See Devise setup for more info
Please ensure you are using Docker Compose V2. This project relies on the docker compose
command, not the previous docker-compose
standalone program.
https://docs.docker.com/compose/#compose-v2-and-the-new-docker-compose-command
Check your docker compose version with:
$ docker compose version
Docker Compose version v2.20.2
You can just run the startup.sh script:
sh ./startup.sh
This will bootstrap a Rails 7 application that has some sample data but misses a lot of features, for example, it has no authentication.
If you want to have built-in authentication with Devise you can do the following:
(optional)
Setting the application up to work with Devise is very straightforward, just a single command:sh startup.sh --devise user
In this case, the application will be created with authentication mechanism for a model called "User".
The given model will be created, migrated and integrated with the application upon startup.
PG::DuplicateColumn: ERROR: column "email" of relation "[DEVISE NAME]" already exists (PG::DuplicateColumn)
Followed by an UI error saying that
You have 1 pending migration:
db/migrate/YYYYMMDDHHMMSS_add_devise_to_[DEVISE NAME].rb
To resolve this issue, you need to either:
- drop and remove the entire container, and run the
startup
script again
or - manually remove the new migration causing the issue and re-run the script with a changed devise name.
Using the startup.sh
script, you can skip the next step and make it so the application starts immediately after it has been built:
sh startup.sh --run # -r works as well :)
If you want to learn more about this script you can just call the --help
option.
docker compose up
Then just navigate to http://localhost:3000
When the app is already running with docker-compose
up, attach to the container:
docker compose exec web bin/rails c
When no container running yet, start up a new one:
docker compose run --rm web bin/rails c
docker compose run --rm web bin/rspec
If you want to change the timezone to your specific locale you can do this very simply, just change the TIMEZONE variable in the .env file:
# TODO: change to CET, EET or wherever you live
TIMEZONE=UTC
docker compose run --rm web bundle
docker compose up --build
docker build -f production.Dockerfile .
This app can be hosted wherever Ruby is supported and PostgreSQL databases can be provisioned.
NOTE: You will need to generate a production secret with bin/rails secret
and set it as the SECRET_KEY_BASE
environment variable.