Skip to content

Commit a4ad9c3

Browse files
committed
build: Update Docker dev setup
1 parent aa58bfa commit a4ad9c3

7 files changed

Lines changed: 45 additions & 24 deletions

File tree

.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ Style/FrozenStringLiteralComment:
4949
Exclude:
5050
- spec/dummy/db/**/schema*.rb
5151

52+
Style/NegatedIfElseCondition:
53+
Exclude:
54+
- Gemfile
55+
5256
Style/NumericLiterals:
5357
Exclude:
5458
- spec/dummy/db/**/schema*.rb

Gemfile

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,46 @@
33
source 'https://rubygems.org'
44
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
55

6+
ruby_ver = ENV.fetch("RUBY_VERSION", "")
7+
rails_ver = ENV.fetch('RAILS_VERSION', "")
8+
69
if ENV['DEVEL'] == '1'
7-
rails_ver = ENV.fetch('RAILS_VERSION')
8-
gem 'rails', rails_ver
10+
if !rails_ver.empty?
11+
gem 'rails', "~> #{rails_ver}"
12+
else
13+
gem 'rails'
14+
end
915

10-
gem 'activeadmin', ENV.fetch('ACTIVEADMIN_VERSION')
1116
gem 'active_storage_db', path: './'
1217
gem 'appraisal', '~> 2.4'
1318
gem 'factory_bot_rails', '~> 6.1'
14-
15-
if rails_ver.start_with?('7.0')
16-
gem 'concurrent-ruby', '1.3.4'
17-
end
1819
else
1920
gemspec
2021
end
2122

22-
if ENV['DB_TEST'] == 'mssql'
23-
gem 'activerecord-sqlserver-adapter', '7.0.3.0'
24-
gem 'tiny_tds'
23+
# DB driver: mssql
24+
gem 'activerecord-sqlserver-adapter'
25+
gem 'tiny_tds'
26+
27+
# DB driver: mysql
28+
gem 'mysql2'
29+
30+
# DB driver: postgres
31+
gem 'pg'
32+
33+
# DB driver: sqlite
34+
if !rails_ver.empty? && Gem::Version.new(rails_ver) < Gem::Version.new('7.2')
35+
gem 'sqlite3', '~> 1.4'
36+
else
37+
gem 'sqlite3'
2538
end
26-
gem 'mysql2' if ENV['DB_TEST'] == 'mysql'
27-
gem 'pg' if ['postgres', 'postgresql'].include? ENV['DB_TEST']
28-
gem 'sqlite3' if ENV['DB_TEST'] == 'sqlite'
39+
40+
if !ruby_ver.empty? && Gem::Version.new(ruby_ver) < Gem::Version.new('3.2')
41+
gem 'zeitwerk', '~> 2.6.18'
42+
end
43+
44+
# NOTE: to avoid error: uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger
45+
gem 'concurrent-ruby', '1.3.4'
2946

3047
gem 'bigdecimal'
3148
gem 'image_processing', '>= 1.2'

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ specs:
3131
docker compose exec app bin/rspec --fail-fast
3232

3333
# Other commands
34+
appraisal_update:
35+
docker compose exec app bin/appraisal update
36+
3437
bundle:
3538
docker compose exec app bundle
3639

docker-compose.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ services:
66
dockerfile: ./extra/Dockerfile
77
args:
88
# Debian-based Ruby image:
9-
RUBY_IMAGE: ruby:3.4-slim
9+
RUBY_IMAGE: ruby:${RUBY:-3.2}-slim
1010
UID: ${UID}
1111
environment:
12-
ACTIVEADMIN_VERSION: ~> 3.3
1312
DB_TEST: sqlite
14-
RAILS_VERSION: ~> 8.0
13+
RAILS_VERSION: ${RAILS:-}
1514
user: "${UID}:${GID}"
1615
ports:
1716
- '3000:3000'

extra/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ ENV LANG=C.UTF-8
88
ENV RAILS_ENV=development
99

1010
RUN apt-get update -qq
11-
RUN DEBIAN_FRONTEND=noninteractive apt-get install -yqq --no-install-recommends build-essential libvips42 libyaml-dev nano
11+
RUN DEBIAN_FRONTEND=noninteractive apt-get install -yqq --no-install-recommends build-essential nano pkg-config \
12+
freetds-dev libmariadb-dev libpq-dev libvips42 libyaml-dev sqlite3
1213

13-
RUN gem install bundler
14+
RUN gem install bundler -v 2.5.23
1415
RUN echo 'gem: --no-document' > /etc/gemrc
1516

1617
RUN useradd -u ${UID} --shell /bin/bash app

extra/dev_setup.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
#!/bin/sh
22

3-
export DEVEL=1
4-
3+
export DB_TEST=sqlite
54
export RAILS_VERSION=8.0.2
6-
export ACTIVEADMIN_VERSION=3.3.0
75

6+
export DEVEL=1
87
export RAILS_ENV=development
9-
10-
export DB_TEST=sqlite

spec/dummy/db/schema_development.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[8.0].define(version: 2022_02_02_010101) do
13+
ActiveRecord::Schema[7.2].define(version: 2022_02_02_010101) do
1414
create_table "active_storage_attachments", force: :cascade do |t|
1515
t.string "name", null: false
1616
t.string "record_type", null: false

0 commit comments

Comments
 (0)