Run this after updating the Gemfile:
docker run --rm -v "$PWD":/app -w /app ruby:3.2.2 bundle installNOTE for Apple silicon users:
export DOCKER_DEFAULT_PLATFORM=linux/amd64docker-compose build webdocker-compose up --detach dbOPTIONAL: Verify the container is up:
docker-compose psdocker-compose run web rails db:createdocker-compose run web rails db:migrateThe schema file can be found at db/schema.rb if you want to commit it.
docker-compose upAccess the application using http://localhost:3000.
If you encounter permission issues with the database container, you may need to update the volumes section in docker-compose.yml. Change:
volumes:
- ./tmp/db:/var/lib/postgresql/dataTo:
volumes:
- db-data:/var/lib/postgresql/dataThis avoids permission issues and aligns with standard practices. Consider whether using tmp has specific purposes before making the change.
If you encounter issues during migrations, try the following commands:
-
Reset the database and rerun migrations:
docker-compose run web rails db:migrate:reset
-
If that doesn’t work, drop and recreate the database:
docker-compose run web rails db:drop docker-compose run web rails db:create
-
Then rerun migrations:
docker-compose run web rails db:migrate