This is a simple way to generate a Rails project using Docker.
You need to have Docker installed on your machine.
$ docker-compose run --no-deps web rails new . --force --database=postgresql --api
$ docker-compose build
$ docker-compose up
$ docker-compose run web rake db:create
$ docker-compose run web rake db:migrate
Add permissions to the directory
$ sudo chown -R $(whoami):$(id -gn) .
- If you want to use a different database, you can change the
database
option in thedocker-compose.yaml
file. - If you want to use a different Ruby version, you can change the
image
option in thedocker-compose.yaml
file and also the version in theGemfile
. - If you want to use a different Rails version, you can change the version in the
Gemfile
.
-
Dockerfile: Defines the image to be used to build the container.
-
docker-compose.yml: Defines the services to be used to build the container.
-
Gemfile: With the gems to be used in the project.
-
Gemfile.lock: Defines the gems to be used in the project.
-
entrypoint.sh: Defines the commands to be executed when the container is started.
-
.dockerignore: Defines the files to be ignored when building the container.
Bug reports and pull requests are welcome