Rails-6-Docker-Alpine

Lightweight Rails 6 App over Docker Alpine images

Stars
20
Committers
1

Rails 6 Docker Alpine

Docker image size

$ docker images
REPOSITORY                                 TAG                       SIZE
blitz_web                                  latest                    390MB

Steps

  1. Clone & Create
git clone [email protected]:zazk/Rails-6-Docker-Alpine.git

Create a new Rails application under the repository directory

cd Rails-6-Docker-Alpine
rails new . --webpack --database=postgresql
  1. Configure:

Modify your database configuration to use the postgresql container configuration:

default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  host: db
  username: postgres

Remove check Yarn

# ./config/environments/development.rb
# Disable Yarn Check
config.webpacker.check_yarn_integrity = false
  1. Build the project:
docker-compose build
  1. Create the database and run the migrations:
docker-compose run --rm web bin/rails db:create
docker-compose run --rm web bin/rails db:migrate
  1. Run the app:
docker-compose up

Visit your application

http://localhost:3000

Troubleshooting

  1. If you have probles with pg gem you should install Postgres before. On Mac brew install postgres
  2. Ruby Version 2.5.3