Skip to content

Commit c570700

Browse files
committed
Update the live demo
1 parent 1b2a8ba commit c570700

File tree

14 files changed

+347
-48
lines changed

14 files changed

+347
-48
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jobs:
150150
run: |
151151
yarn install
152152
cd spec/dummy_app
153-
bundle exec rake rails_admin:prepare_ci_env db:create db:migrate
153+
bundle exec rake rails_admin:prepare_ci_env db:create db:schema:load
154154
yarn install
155155
case "$CI_ASSET" in
156156
"webpack" ) yarn build && yarn build:css ;;

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ log/*.log
2424
pkg/*
2525
spec/dummy_app/db/*.sqlite3
2626
spec/dummy_app/db/*.sqlite3-journal
27-
spec/dummy_app/db/schema.rb
2827
spec/dummy_app/log/*.log
2928
spec/dummy_app/public/uploads
3029
spec/dummy_app/Gemfile*.lock

spec/dummy_app/.dockerignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
# Ignore git directory.
44
/.git/
55

6-
# Ignore bundler config.
6+
# Ignore bundler config and Gemfile.lock.
77
/.bundle
8+
/Gemfile.lock
89

910
# Ignore all default key files.
1011
/config/master.key
@@ -26,6 +27,10 @@
2627
!/tmp/pids/.keep
2728

2829
# Ignore storage (uploaded files in development and any SQLite databases).
30+
/db/*.sqlite3
31+
/public/system
32+
/public/uploads
33+
/public/vite
2934
/storage/*
3035
!/storage/.keep
3136
/tmp/storage/*

spec/dummy_app/Dockerfile

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# syntax = docker/dockerfile:1
22

33
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
4-
ARG RUBY_VERSION=3.1.2
5-
FROM ruby:$RUBY_VERSION-slim as base
4+
ARG RUBY_VERSION=3.1
5+
FROM ruby:$RUBY_VERSION-slim AS base
66

77
LABEL fly_launch_runtime="rails"
88

@@ -30,17 +30,18 @@ RUN apt-get update -qq && \
3030
# rm -rf /tmp/node-build-master
3131

3232
# Throw-away build stage to reduce size of final image
33-
FROM base as build
33+
FROM base AS build
3434

3535
# Install packages needed to build gems and node modules
3636
RUN apt-get update -qq && \
37-
apt-get install --no-install-recommends -y build-essential default-libmysqlclient-dev git libpq-dev libvips node-gyp pkg-config python-is-python3
37+
apt-get install --no-install-recommends -y build-essential default-libmysqlclient-dev git libpq-dev libvips libyaml-dev node-gyp pkg-config python-is-python3
3838

3939
# Build options
4040
ENV PATH="/usr/local/node/bin:$PATH"
4141

42-
# Install application gems
43-
COPY --link Gemfile ./
42+
# Copy application code
43+
COPY --link . .
44+
4445
RUN sed -i "s/, path: '..\/..\/'//" Gemfile
4546
RUN bundle install && \
4647
rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git
@@ -49,21 +50,16 @@ RUN bundle install && \
4950
# COPY --link package.json ./
5051
# RUN npm install
5152

52-
# Copy application code
53-
COPY --link . .
54-
RUN sed -i "s/, path: '..\/..\/'//" Gemfile
55-
5653
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
5754
RUN sed -i "/link_tree ..\/..\/..\//d" app/assets/config/manifest.js
58-
RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile
59-
55+
RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile db:setup
6056

6157
# Final stage for app image
6258
FROM base
6359

6460
# Install packages needed for deployment
6561
RUN apt-get update -qq && \
66-
apt-get install --no-install-recommends -y curl default-mysql-client imagemagick libsqlite3-0 libvips postgresql-client && \
62+
apt-get install --no-install-recommends -y curl imagemagick libsqlite3-0 libvips && \
6763
rm -rf /var/lib/apt/lists /var/cache/apt/archives
6864

6965
# Copy built artifacts: gems, application
@@ -72,12 +68,14 @@ COPY --from=build /rails /rails
7268

7369
# Run and own only the runtime files as a non-root user for security
7470
RUN useradd rails --create-home --shell /bin/bash && \
71+
mkdir public/system public/uploads && \
7572
chown -R rails:rails db log tmp public/system public/uploads
7673
USER rails:rails
7774

7875
# Deployment options
7976
ENV RAILS_LOG_TO_STDOUT="1" \
80-
RAILS_SERVE_STATIC_FILES="true"
77+
RAILS_SERVE_STATIC_FILES="true" \
78+
RAILS_MAX_THREADS="1"
8179

8280
# Entrypoint prepares the database.
8381
ENTRYPOINT ["/rails/bin/docker-entrypoint"]

spec/dummy_app/Gemfile

+12-9
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,36 @@ gem 'rails', '>= 7.0.0'
66

77
group :active_record do
88
platforms :jruby do
9-
gem 'activerecord-jdbcmysql-adapter', '>= 1.2'
10-
gem 'activerecord-jdbcpostgresql-adapter', '>= 1.2'
9+
gem 'activerecord-jdbcmysql-adapter', '>= 1.2' if ENV['CI_DB_ADAPTER'] == 'mysql2'
10+
gem 'activerecord-jdbcpostgresql-adapter', '>= 1.2' if ENV['CI_DB_ADAPTER'] == 'postgresql'
1111
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.2'
1212
end
1313

1414
platforms :ruby, :mswin, :mingw do
15-
gem 'mysql2', '>= 0.3.14'
16-
gem 'pg', '>= 0.14'
15+
gem 'mysql2', '>= 0.3.14' if ENV['CI_DB_ADAPTER'] == 'mysql2'
16+
gem 'pg', '>= 0.14' if ENV['CI_DB_ADAPTER'] == 'postgresql'
1717
gem 'sqlite3', '>= 1.3.0'
1818
end
1919

2020
gem 'paper_trail', '>= 12.0'
2121
end
2222

2323
gem 'carrierwave', '>= 2.0.0.rc', '< 3.0'
24-
gem 'cssbundling-rails', require: false
2524
gem 'devise', '>= 3.2'
2625
gem 'dragonfly', '~> 1.0'
27-
gem 'importmap-rails', require: false
2826
gem 'mini_magick', '>= 3.4'
2927
gem 'mlb', '>= 0.7'
3028
gem 'paperclip', '>= 3.4'
29+
gem 'puma'
3130
gem 'rails_admin', path: '../../'
3231
gem 'shrine', '~> 3.0'
33-
gem 'vite_rails', require: false
34-
gem 'webpacker', require: false
35-
gem 'webrick'
32+
33+
group :development, :test do
34+
gem 'cssbundling-rails', require: false
35+
gem 'importmap-rails', require: false
36+
gem 'vite_rails', require: false
37+
gem 'webpacker', require: false
38+
end
3639

3740
# Gems used only for assets and not required
3841
# in production environments by default.

spec/dummy_app/bin/docker-entrypoint

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
#!/bin/bash -e
22

3-
# If running the rails server then create or migrate existing database
4-
if [ "${*}" == "./bin/rails server" ]; then
5-
./bin/rails db:create db:migrate db:seed
6-
fi
7-
83
exec "${@}"

spec/dummy_app/config/application.rb

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Application < Rails::Application
3737
# Application configuration should go into files in config/initializers
3838
# -- all .rb files in that directory are automatically loaded.
3939
config.load_defaults Rails.version[0, 3]
40+
(CI_TARGET_ORMS - [CI_ORM]).each {|orm| config.paths.add "app/#{orm}", eager_load: false }
4041
config.eager_load_paths = (config.try(:all_eager_load_paths) || config.eager_load_paths).reject { |p| p =~ %r{/app/([^/]+)} && !%W[controllers jobs locales mailers #{CI_ORM}].include?(Regexp.last_match[1]) }
4142
config.eager_load_paths += %W[#{config.root}/app/eager_loaded]
4243
config.autoload_paths += %W[#{config.root}/lib]

spec/dummy_app/config/boot.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
CI_ORM = (ENV['CI_ORM'] || :active_record).to_sym unless defined?(CI_ORM)
4+
CI_TARGET_ORMS = %i[active_record mongoid].freeze
45
CI_ASSET = (ENV['CI_ASSET'] || :sprockets).to_sym unless defined?(CI_ASSET)
56
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
67

spec/dummy_app/config/environments/production.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
# Use the lowest log level to ensure availability of diagnostic information
5252
# when problems arise.
53-
config.log_level = :debug
53+
config.log_level = :info
5454

5555
# Prepend all log lines with the following tags.
5656
# config.log_tags = [ :subdomain, :request_id ]
@@ -82,4 +82,7 @@
8282

8383
# Do not dump schema after migrations.
8484
config.active_record.dump_schema_after_migration = false
85+
86+
# Disable yjit to save memory.
87+
config.yjit = false
8588
end

spec/dummy_app/config/initializers/rails_admin.rb

+5
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,10 @@
1616
visible false
1717
end
1818
end
19+
c.model 'League' do
20+
configure :players do
21+
visible false
22+
end
23+
end
1924
end
2025
end

spec/dummy_app/config/puma.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# frozen_string_literal: true
2+
3+
threads 0, ENV.fetch("RAILS_MAX_THREADS", 3)
4+
port ENV.fetch("PORT", 3000)

0 commit comments

Comments
 (0)