Skip to content
Template for Rails 6.0 + Docker Compose + Webpacker + Stimulus + Nginx Proxy + Let's Encrypt + @
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app add force option for copying javascript/index.js May 6, 2019
config minor fix Mar 5, 2019
docker fix Dockerfile's case letter May 8, 2019
lib
spec update Apr 10, 2019
.gitignore Version 1.0 Mar 5, 2019
Gemfile.tt update ruby version with bug fix for nginx proxy support Apr 14, 2019
Procfile Version 1.0 Mar 5, 2019
README.md seperate sidekiq / add volume for redis / update README.md May 6, 2019
docker-compose.yml.tt seperate sidekiq / add volume for redis / update README.md May 6, 2019
gitignore Version 1.0 Mar 5, 2019
ruby-version.tt Version 1.0 Mar 5, 2019
template.rb change bundler's version above 2 May 8, 2019

README.md

rails-template

Description

Simple rails template for general project.

Requirements

  • Rails 6.0.x
  • PostgreSQL

Installation

To generate a Rails application using this template, pass the -m option to rails new, like this:

rails new project -T -d postgresql \
    -m https://raw.githubusercontent.com/astrocket/rails-template/master/template.rb

Remember that options must go after the name of the application. The only database supported by this template is postgresql.

What's included?

  • Docker for production deploy
  • Nginx Proxy server configuration with Let's encrypt SSL Certificate
  • Webpacker and Stimulus setting for client javascript
  • ActiveJob + Sidekiq + Redis setting for async jobs
  • Foreman setting for integrative dev setup
  • Rspec + FactoryBot setting for test code
  • Guard + LiveReload setting for hot reloading

Foreman start task

Procfile-based applications

with rails hot

It runs

  • rails
  • webpacker
  • guard
  • sidekiq

Stimulus generator

Stimulus specific generator task.

with rails g stimulus posts index

It generates

  • app/javascript/posts/index_controller.js with sample html markup containing stimulus path helper.

Production deploy process

After installing docker & docker-compose in your host machine.

Set up a seperate Nginx-Proxy docker container in your host machine. link

git clone https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion.git
cd docker-compose-letsencrypt-nginx-proxy-companion
mv .env.sample .env
./start.sh

Clone your repository to host machine and build docker-compose.

git clone http://github.com/username/your_own_rails_repository
docker-compose build
docker-compose up -d

Scale your rails application to 5 replicas.

docker-compose up -d --scale app=5

Automated deploy task

After pushing repository to git and providing deployment information in lib/tasks/deploy.rake file. You can automate above process.

rails deploy:production

Testing

rspec-rails factory-bot

Run test specs

bundle exec rspec

scale docker containers

Docker CMDs

To see your live container log

docker ps
docker log -f processid

Check images / containers

docker images -a
docker container ls -a

Remove all abandonded images

docker rmi -f $(docker images -a | grep "none" | awk '{print $3}')

Destry all exited containers remove scientist name containers

docker container rm $(docker container ls -aq --filter status=exited)

Prune (be careful)

docker container prune
docker image prune
docker network prune
docker volume prune

Stop and delete specific container

docker stop processid
docker rm processid
You can’t perform that action at this time.