Run the following command to generate a new rails app without any ruby installation in the host machine. it just needs Docker.
export APP_NAME=myapp ; docker run --rm -v ${PWD}:/$APP_NAME -w /$APP_NAME -t ruby:slim \
sh -c "apt update && apt install -y --no-install-recommends git build-essential libpq-dev\
&& gem install -N rails -v '~>7' \
&& rails new $APP_NAME --database=postgresql --skip-system-test --skip-test \
&& chown -R $(id -u):$(id -g) $APP_NAME/"
Because I'm running this command in Manjaro Linux, I need to chown the generated files to my linux user host otherwise the owner would be root and wouldn't be able to do any changes. This chown
command is not needed in MacOS.
The workdir path can define the rails application name. Hence with the above command, if we were generated the rails app with the command rails new . --database= ...
you'll get app name from the parent folder and you can confirm that checking the config/application.rb
file:
We're skiping the rails default testing becuase usually we setup RSpec as the testing framework