A template to create a rails 7 dev container.
-
create a repo from this template.
-
clone the repo to your local
-
start a dev container for your local repo.
I tried 1. vscode, 2. neovim + nvim-dev-container. both are ok.
-
In your dev container
-
(optional)
service start cron
if you need crontab to work. -
Generate your rails project in the dev container.
# importmaps + propshaft (my prefer) rails new . -a propshaft -d=postgresql # or, one of the following # importmaps + sprockets rails new . -d=postgresql # importmaps + sprockets + tailwind, https://techracho.bpsinc.jp/hachi8833/2022_02_17/115435 rails new . --css tailwind -d=postgresql # importmaps + propshaft + tailwind rails new . --css tailwind -a propshaft -d=postgresql # (nodejs) esbuild + sprockets + tailwind rails new . --javascript esbuild --css tailwind -d=postgresql # (nodejs) esbuild + propshaft + bootstrap rails new . --javascript esbuild --css bootstrap -a propshaft -d=postgresql
-
fix config/database.yml by adding the
host
,username
andpassword
to the development section.... default: &default ... host: <%= ENV.fetch("DB_HOST") { "db" } %> username: <%= ENV.fetch("DB_USERNAME") { "postgres" } %> password: <%= ENV.fetch("DB_PASSWORD") { "password" } %> ...
bundle exec rails db:create
-
run your app in the container.
./bin/dev
-
-
now, everything is ready.