Skip to content

Commit

Permalink
Upgrade to Rails 7 and swap Webpacker with esbuild
Browse files Browse the repository at this point in the history
This is a big commit. The changelog sums most things up.
  • Loading branch information
nickjj committed Dec 18, 2021
1 parent 1f136a7 commit c2b0a41
Show file tree
Hide file tree
Showing 59 changed files with 653 additions and 3,881 deletions.
1 change: 0 additions & 1 deletion .browserslistrc

This file was deleted.

6 changes: 2 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.git/
log/*
!log/.keep
app/assets/builds/*
!app/assets/builds/.keep
node_modules/
public/assets/
public/packs/
public/packs-test/
storage/*
!storage/.keep
tmp/*
Expand All @@ -16,8 +16,6 @@ tmp/*
.env*
!.env.example
config/master.key
config/credentials/development.key
config/credentials/production.key
docker-compose.override.yml
yarn-error.log
yarn-debug.log*
Expand Down
Binary file modified .github/docs/screenshot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ storage/*

# Ignore master key for decrypting credentials.
config/master.key
config/credentials/development.key
config/credentials/production.key

# Ignore front-end related files.
app/assets/builds/*
!app/assets/builds/.keep
node_modules/
public/assets/
public/packs/
public/packs-test/
yarn-error.log
yarn-debug.log*
.yarn-integrity
Expand Down
48 changes: 38 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,60 @@ Changelog](https://keepachangelog.com/en/1.0.0/).

### Added

- esbuild and tailwindcss based on Rails 7
- Lint Dockerfile with <https://github.com/hadolint/hadolint>
- `./run test` which runs `rails test` but also optionally builds your JS / CSS with `./run test -b`

### Changed

- Use the Docker Compose spec in `docker-compose.yml` (removes version: property)
- Rename `webpacker` Docker build stage to `assets`
- Base application has been freshly generated by Rails 7.0.0
- Only install and enable bootsnap in non-production environments
- Update `tailwind.config.js` based on the new TailwindCSS v3 defaults

#### Languages and services

- Update `Ruby` to `3.0.2` and switch to Debian Bullseye Slim
- Update `Ruby` to `3.0.3` and switch to Debian Bullseye Slim
- Update `Node` to `16.x`
- Update `PostgreSQL` to `14.0`
- Update `Redis` to `6.2.6`

#### Back-end dependencies

- Update `bootsnap` to `1.7.7`
- Update `listen` to `3.7.0`
- Update `puma` to `5.4.0`
- Update `rails` to `6.1.4.1`
- Update `redis` to `4.4.0`
- Update `turbo-rails` to `0.7.4`
- Update `webdrivers` to `4.6.1`
- Update `bootsnap` to `1.9.3`
- Update `capybara` to `3.36.0`
- Update `cssbundling-rails` to `1.0.0`
- Update `jbuilder` to `2.11.4`
- Update `jsbundling-rails` to `1.0.0`
- Update `puma` to `5.5.2`
- Update `rack-mini-profiler` to `2.3.3`
- Update `rails` to `7.0.0`
- Update `redis` to `4.5.1`
- Update `selenium-webdriver` to `4.1.0`
- Update `sidekiq` to `6.3.1`
- Update `sprockets-rails` to `3.4.2`
- Update `stimulus-rails` to `1.0.2`
- Update `turbo-rails` to `1.0.0`
- Update `web-console` to `4.2.0`
- Update `webdrivers` to `5.0.0`

#### Front-end dependencies

- Update `@hotwired/turbo-rails` to `7.0.0-rc.1`
- Update `tailwindcss` to `3.0.0`
- Update `@hotwired/stimulus` to `3.0.1`
- Update `@hotwired/turbo-rails` to `7.1.0`
- Update `@rails/activestorage` to `7.0.0`
- Update `autoprefixer` `10.4.0`
- Update `esbuild` `0.14.5`
- Update `postcss-import` `14.0.2`
- Update `postcss` `8.4.5`
- Update `tailwindcss` to `3.0.7`

### Removed

- All traces of Webpacker
- Channel related JavaScript (this isn't added by default with Rails 7 and Hotwire is available now)
- `tailwindcss-stimulus-components` front-end package

## [0.4.0] - 2021-07-01

Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM ruby:3.0.2-slim-bullseye AS webpacker
FROM ruby:3.0.3-slim-bullseye AS assets
LABEL maintainer="Nick Janetakis <nick.janetakis@gmail.com>"

WORKDIR /app

RUN bash -c "set -o pipefail && apt-get update \
&& apt-get install -y --no-install-recommends build-essential curl git libpq-dev \
&& curl -sSL https://deb.nodesource.com/setup_14.x | bash - \
&& curl -sSL https://deb.nodesource.com/setup_16.x | bash - \
&& curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo 'deb https://dl.yarnpkg.com/debian/ stable main' | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update && apt-get install -y --no-install-recommends nodejs yarn \
Expand All @@ -26,7 +26,7 @@ ARG RAILS_ENV="production"
ARG NODE_ENV="production"
ENV RAILS_ENV="${RAILS_ENV}" \
NODE_ENV="${NODE_ENV}" \
PATH="${PATH}:/home/ruby/.local/bin" \
PATH="${PATH}:/home/ruby/.local/bin:/node_modules/.bin" \
USER="ruby"

COPY --chown=ruby:ruby . .
Expand All @@ -38,7 +38,7 @@ CMD ["bash"]

###############################################################################

FROM ruby:3.0.2-slim-bullseye AS app
FROM ruby:3.0.3-slim-bullseye AS app
LABEL maintainer="Nick Janetakis <nick.janetakis@gmail.com>"

WORKDIR /app
Expand All @@ -60,8 +60,8 @@ ENV RAILS_ENV="${RAILS_ENV}" \
PATH="${PATH}:/home/ruby/.local/bin" \
USER="ruby"

COPY --chown=ruby:ruby --from=webpacker /usr/local/bundle /usr/local/bundle
COPY --chown=ruby:ruby --from=webpacker /app/public /public
COPY --chown=ruby:ruby --from=assets /usr/local/bundle /usr/local/bundle
COPY --chown=ruby:ruby --from=assets /app/public /public
COPY --chown=ruby:ruby . .

ENTRYPOINT ["/app/bin/docker-entrypoint-web"]
Expand Down
97 changes: 57 additions & 40 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,55 +1,72 @@
source 'https://rubygems.org'
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.0.2'
ruby "3.0.3"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.0"

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '6.1.4.1'
# Use postgresql as the database for Active Record
gem 'pg', '~> 1.1'
# Use Puma as the app server
gem 'puma', '5.4.0'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '6.0.0.beta.7'
# Hotwire (HTML over the wire). Read more: https://hotwire.dev/
gem 'turbo-rails', '0.7.4'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
gem "pg", "~> 1.1"

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.0"

# Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
gem "jsbundling-rails"

# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"

# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"

# Bundle and process CSS [https://github.com/rails/cssbundling-rails]
gem "cssbundling-rails"

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"

# Use Redis adapter to run Action Cable in production
gem 'redis', '4.4.0'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '1.7.7', require: false
gem "redis", "~> 4.0"

# Execute jobs in the background. Read more: https://github.com/mperham/sidekiq
gem 'sidekiq', '~> 6.2.1'
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

# Execute jobs in the background [https://github.com/mperham/sidekiq]
gem "sidekiq", "~> 6.3"

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false
end

group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 4.1.0'
# Display performance information such as SQL time and flame graphs for each request in your browser.
# Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
gem 'rack-mini-profiler', '~> 2.0'
gem 'listen', '3.7.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"

# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
gem "rack-mini-profiler"

# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"
end

group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 3.26'
gem 'selenium-webdriver'
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
# Required for Ruby 3+
gem 'rexml', '~> 3.2'
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "selenium-webdriver"
gem "webdrivers"
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Loading

0 comments on commit c2b0a41

Please sign in to comment.