A template to create a rails7 dev container.
-
create a project from this template. for example
try_rails7
-
In your dev container
- (optional)
service start cron
if you need crontab to work. - Generate your rails project in the dev container.
For example, the commands below will create a new Rails project using the Rails 7 default assets pipeline which is my favorite.
gem install rails rails new . --force -d=postgresql
- fix config/database.yml by adding the
host
,username
andpassword
to the development section.... development: <<: *default database: try_rails7_development host: <%= ENV.fetch("DB_HOST") { "db" } %> username: <%= ENV.fetch("DB_USERNAME") { "postgres" } %> password: <%= ENV.fetch("DB_PASSWORD") { "password" } %> ...
- run your app in the container.
bundle exec rails s -p 3000 -b '0.0.0.0'
- (optional)
-
now, everything is ready.