Skip to content

Commit 5ca8ccb

Browse files
committed
Revive the live demo
Closes #3537, Refs. #3635
1 parent 2379583 commit 5ca8ccb

12 files changed

+185
-7
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ RailsAdmin is a Rails engine that provides an easy-to-use interface for managing
1919
- Check out [the docs][docs].
2020
- Try the [live demo][demo]. ([Source code][dummy_app])
2121

22-
[demo]: http://rails-admin-tb.herokuapp.com/
23-
[dummy_app]: https://github.com/bbenezech/dummy_app
22+
[demo]: https://rails-admin.fly.dev/admin/
23+
[dummy_app]: https://github.com/railsadminteam/rails_admin/tree/master/spec/dummy_app
2424
[docs]: https://github.com/railsadminteam/rails_admin/wiki
2525

2626
## Features

spec/dummy_app/.dockerignore

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
2+
3+
# Ignore git directory.
4+
/.git/
5+
6+
# Ignore bundler config.
7+
/.bundle
8+
9+
# Ignore all default key files.
10+
/config/master.key
11+
/config/credentials/*.key
12+
13+
# Ignore all environment files.
14+
/.env*
15+
!/.env.example
16+
17+
# Ignore all logfiles and tempfiles.
18+
/log/*
19+
/tmp/*
20+
!/log/.keep
21+
!/tmp/.keep
22+
23+
# Ignore pidfiles, but keep the directory.
24+
/tmp/pids/*
25+
!/tmp/pids/
26+
!/tmp/pids/.keep
27+
28+
# Ignore storage (uploaded files in development and any SQLite databases).
29+
/storage/*
30+
!/storage/.keep
31+
/tmp/storage/*
32+
!/tmp/storage/
33+
!/tmp/storage/.keep
34+
35+
# Ignore assets.
36+
/node_modules/
37+
/app/assets/builds/*
38+
!/app/assets/builds/.keep
39+
/public/assets

spec/dummy_app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
/public/system
2121

22+
/public/assets
2223
/public/packs
2324
/public/packs-test
2425
/node_modules

spec/dummy_app/Dockerfile

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# syntax = docker/dockerfile:1
2+
3+
# 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
6+
7+
LABEL fly_launch_runtime="rails"
8+
9+
# Rails app lives here
10+
WORKDIR /rails
11+
12+
# Set production environment
13+
ENV RAILS_ENV="production" \
14+
BUNDLE_WITHOUT="development:test"
15+
16+
# Update gems and bundler
17+
RUN gem update --system --no-document && \
18+
gem install -N bundler
19+
20+
# Install packages needed to install nodejs
21+
RUN apt-get update -qq && \
22+
apt-get install --no-install-recommends -y curl && \
23+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
24+
25+
# Install Node.js
26+
# ARG NODE_VERSION=18.16.0
27+
# ENV PATH=/usr/local/node/bin:$PATH
28+
# RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
29+
# /tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
30+
# rm -rf /tmp/node-build-master
31+
32+
# Throw-away build stage to reduce size of final image
33+
FROM base as build
34+
35+
# Install packages needed to build gems and node modules
36+
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
38+
39+
# Build options
40+
ENV PATH="/usr/local/node/bin:$PATH"
41+
42+
# Install application gems
43+
COPY --link Gemfile ./
44+
RUN sed -i "s/, path: '..\/..\/'//" Gemfile
45+
RUN bundle install && \
46+
rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git
47+
48+
# Install node modules
49+
# COPY --link package.json ./
50+
# RUN npm install
51+
52+
# Copy application code
53+
COPY --link . .
54+
RUN sed -i "s/, path: '..\/..\/'//" Gemfile
55+
56+
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
57+
RUN sed -i "/link_tree ..\/..\/..\//d" app/assets/config/manifest.js
58+
RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile
59+
60+
61+
# Final stage for app image
62+
FROM base
63+
64+
# Install packages needed for deployment
65+
RUN apt-get update -qq && \
66+
apt-get install --no-install-recommends -y curl default-mysql-client imagemagick libsqlite3-0 libvips postgresql-client && \
67+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
68+
69+
# Copy built artifacts: gems, application
70+
COPY --from=build /usr/local/bundle /usr/local/bundle
71+
COPY --from=build /rails /rails
72+
73+
# Run and own only the runtime files as a non-root user for security
74+
RUN useradd rails --create-home --shell /bin/bash && \
75+
chown -R rails:rails db log tmp public/system public/uploads
76+
USER rails:rails
77+
78+
# Deployment options
79+
ENV RAILS_LOG_TO_STDOUT="1" \
80+
RAILS_SERVE_STATIC_FILES="true"
81+
82+
# Entrypoint prepares the database.
83+
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
84+
85+
# Start the server by default, this can be overwritten at runtime
86+
EXPOSE 3000
87+
CMD ["./bin/rails", "server"]

spec/dummy_app/Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ group :active_record do
2222
end
2323

2424
gem 'carrierwave', '>= 2.0.0.rc', '< 3.0'
25-
gem 'cssbundling-rails'
25+
gem 'cssbundling-rails', require: false
2626
gem 'devise', '>= 3.2'
2727
gem 'dragonfly', '~> 1.0'
2828
gem 'importmap-rails', require: false

spec/dummy_app/bin/docker-entrypoint

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash -e
2+
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+
8+
exec "${@}"

spec/dummy_app/config/database.yml

+4
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ development:
3030
test:
3131
<<: *sqlite
3232
database: db/test.sqlite3
33+
34+
production:
35+
<<: *sqlite
36+
database: db/production.sqlite3

spec/dummy_app/config/dockerfile.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# generated by dockerfile-rails
2+
---
3+
options:
4+
label:
5+
fly_launch_runtime: rails
6+
sentry: false

spec/dummy_app/config/environments/production.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
config.static_cache_control = 'public, max-age=31536000'
2323

2424
# Compress JavaScripts and CSS.
25-
config.assets.js_compressor = :uglifier
25+
# config.assets.js_compressor = :uglifier
2626
# config.assets.css_compressor = :sass
2727

2828
# Do not fallback to assets pipeline if a precompiled asset is missed.

spec/dummy_app/config/initializers/dragonfly.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
require 'dragonfly'
44

5+
# Logger
6+
Dragonfly.logger = Rails.logger
7+
58
# Configure
69
Dragonfly.app.configure do
710
plugin :imagemagick
@@ -16,8 +19,5 @@
1619
server_root: Rails.root.join('public'))
1720
end
1821

19-
# Logger
20-
Dragonfly.logger = Rails.logger
21-
2222
# Mount as middleware
2323
Rails.application.middleware.use Dragonfly::Middleware

spec/dummy_app/config/initializers/rails_admin.rb

+11
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,15 @@
66
include_all_fields
77
field :color, :hidden
88
end
9+
10+
if Rails.env.production?
11+
# Live demo configuration
12+
c.main_app_name = ['RailsAdmin', 'Live Demo']
13+
c.included_models = %w[Comment Division Draft Fan FieldTest League NestedFieldTest Player Team User]
14+
c.model 'FieldTest' do
15+
configure :paperclip_asset do
16+
visible false
17+
end
18+
end
19+
end
920
end

spec/dummy_app/fly.toml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# fly.toml app configuration file generated for rails-admin on 2023-08-06T18:22:31+09:00
2+
#
3+
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
4+
#
5+
6+
app = "rails-admin"
7+
primary_region = "iad"
8+
console_command = "/rails/bin/rails console"
9+
10+
[build]
11+
12+
[http_service]
13+
internal_port = 3000
14+
force_https = true
15+
auto_stop_machines = true
16+
auto_start_machines = true
17+
min_machines_running = 0
18+
processes = ["app"]
19+
20+
[[statics]]
21+
guest_path = "/rails/public"
22+
url_prefix = "/"

0 commit comments

Comments
 (0)