Initial Rails test app

This commit is contained in:
Min Zeya Phyo
2026-01-15 12:26:30 +06:30
commit 1733430341
19 changed files with 418 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
*.log
tmp/
.bundle
vendor/bundle
node_modules/
.env

18
Dockerfile Normal file
View File

@@ -0,0 +1,18 @@
FROM ruby:3.2-slim
RUN apt-get update -qq && \
apt-get install -y build-essential libmariadb-dev git curl && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY Gemfile Gemfile.lock ./
RUN bundle install
COPY . .
RUN bundle exec rails assets:precompile 2>/dev/null || true
EXPOSE 3000
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]

12
Gemfile Normal file
View File

@@ -0,0 +1,12 @@
source 'https://rubygems.org'
ruby '3.2.0'
gem 'rails', '~> 7.1.0'
gem 'mysql2', '~> 0.5'
gem 'puma', '~> 6.0'
gem 'bootsnap', require: false
group :development, :test do
gem 'debug', platforms: %i[mri windows]
end

244
Gemfile.lock Normal file
View File

@@ -0,0 +1,244 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (7.1.6)
actionpack (= 7.1.6)
activesupport (= 7.1.6)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (7.1.6)
actionpack (= 7.1.6)
activejob (= 7.1.6)
activerecord (= 7.1.6)
activestorage (= 7.1.6)
activesupport (= 7.1.6)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.1.6)
actionpack (= 7.1.6)
actionview (= 7.1.6)
activejob (= 7.1.6)
activesupport (= 7.1.6)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.2)
actionpack (7.1.6)
actionview (= 7.1.6)
activesupport (= 7.1.6)
cgi
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
actiontext (7.1.6)
actionpack (= 7.1.6)
activerecord (= 7.1.6)
activestorage (= 7.1.6)
activesupport (= 7.1.6)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.1.6)
activesupport (= 7.1.6)
builder (~> 3.1)
cgi
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (7.1.6)
activesupport (= 7.1.6)
globalid (>= 0.3.6)
activemodel (7.1.6)
activesupport (= 7.1.6)
activerecord (7.1.6)
activemodel (= 7.1.6)
activesupport (= 7.1.6)
timeout (>= 0.4.0)
activestorage (7.1.6)
actionpack (= 7.1.6)
activejob (= 7.1.6)
activerecord (= 7.1.6)
activesupport (= 7.1.6)
marcel (~> 1.0)
activesupport (7.1.6)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
mutex_m
securerandom (>= 0.3)
tzinfo (~> 2.0)
base64 (0.3.0)
benchmark (0.5.0)
bigdecimal (4.0.1)
bootsnap (1.21.1)
msgpack (~> 1.2)
builder (3.3.0)
cgi (0.5.1)
concurrent-ruby (1.3.6)
connection_pool (3.0.2)
crass (1.0.6)
date (3.5.1)
debug (1.11.1)
irb (~> 1.10)
reline (>= 0.3.8)
drb (2.2.3)
erb (6.0.1)
erubi (1.13.1)
globalid (1.3.0)
activesupport (>= 6.1)
i18n (1.14.8)
concurrent-ruby (~> 1.0)
io-console (0.8.2)
irb (1.16.0)
pp (>= 0.6.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
logger (1.7.0)
loofah (2.25.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.9.0)
logger
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.1.0)
mini_mime (1.1.5)
minitest (6.0.1)
prism (~> 1.5)
msgpack (1.8.0)
mutex_m (0.3.0)
mysql2 (0.5.7)
bigdecimal
net-imap (0.6.2)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.5.1)
net-protocol
nio4r (2.7.5)
nokogiri (1.19.0-aarch64-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.0-aarch64-linux-musl)
racc (~> 1.4)
nokogiri (1.19.0-arm-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.0-arm-linux-musl)
racc (~> 1.4)
nokogiri (1.19.0-arm64-darwin)
racc (~> 1.4)
nokogiri (1.19.0-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.19.0-x86_64-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.0-x86_64-linux-musl)
racc (~> 1.4)
pp (0.6.3)
prettyprint
prettyprint (0.2.0)
prism (1.8.0)
psych (5.3.1)
date
stringio
puma (6.6.1)
nio4r (~> 2.0)
racc (1.8.1)
rack (3.2.4)
rack-session (2.1.1)
base64 (>= 0.1.0)
rack (>= 3.0.0)
rack-test (2.2.0)
rack (>= 1.3)
rackup (2.3.1)
rack (>= 3)
rails (7.1.6)
actioncable (= 7.1.6)
actionmailbox (= 7.1.6)
actionmailer (= 7.1.6)
actionpack (= 7.1.6)
actiontext (= 7.1.6)
actionview (= 7.1.6)
activejob (= 7.1.6)
activemodel (= 7.1.6)
activerecord (= 7.1.6)
activestorage (= 7.1.6)
activesupport (= 7.1.6)
bundler (>= 1.15.0)
railties (= 7.1.6)
rails-dom-testing (2.3.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.2)
loofah (~> 2.21)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (7.1.6)
actionpack (= 7.1.6)
activesupport (= 7.1.6)
cgi
irb
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
tsort (>= 0.2)
zeitwerk (~> 2.6)
rake (13.3.1)
rdoc (7.1.0)
erb
psych (>= 4.0.0)
tsort
reline (0.6.3)
io-console (~> 0.5)
securerandom (0.4.1)
stringio (3.2.0)
thor (1.5.0)
timeout (0.6.0)
tsort (0.2.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
websocket-driver (0.8.0)
base64
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.7.4)
PLATFORMS
aarch64-linux-gnu
aarch64-linux-musl
arm-linux-gnu
arm-linux-musl
arm64-darwin
x86_64-darwin
x86_64-linux
x86_64-linux-gnu
x86_64-linux-musl
DEPENDENCIES
bootsnap
debug
mysql2 (~> 0.5)
puma (~> 6.0)
rails (~> 7.1.0)
RUBY VERSION
ruby 3.4.7p58
BUNDLED WITH
2.6.9

2
Rakefile Normal file
View File

@@ -0,0 +1,2 @@
require_relative "config/application"
Rails.application.load_tasks

View File

@@ -0,0 +1,2 @@
class ApplicationController < ActionController::Base
end

View File

@@ -0,0 +1,19 @@
class HomeController < ApplicationController
def index
@db_status = check_database
@timestamp = Time.current
end
def health
render json: { status: "ok", database: check_database, timestamp: Time.current }
end
private
def check_database
ActiveRecord::Base.connection.execute("SELECT 1")
"connected"
rescue => e
"error: #{e.message}"
end
end

View File

@@ -0,0 +1,20 @@
<div class="container">
<h1>Rails Test Application</h1>
<p>Unity Platform - Coolify Deployment Test</p>
<h3>Status</h3>
<div class="status <%= @db_status == 'connected' ? 'ok' : 'error' %>">
Database: <strong><%= @db_status %></strong>
</div>
<h3>Environment</h3>
<ul>
<li>Rails Version: <code><%= Rails.version %></code></li>
<li>Ruby Version: <code><%= RUBY_VERSION %></code></li>
<li>Environment: <code><%= Rails.env %></code></li>
<li>Server Time: <code><%= @timestamp %></code></li>
</ul>
<h3>Health Endpoint</h3>
<p>Check <a href="/health">/health</a> for JSON status</p>
</div>

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>Rails Test App</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 800px; margin: 50px auto; padding: 20px; background: #f5f5f5; }
.container { background: white; padding: 40px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
h1 { color: #cc0000; }
.status { padding: 10px 20px; border-radius: 5px; margin: 10px 0; }
.status.ok { background: #d4edda; color: #155724; }
.status.error { background: #f8d7da; color: #721c24; }
code { background: #e9ecef; padding: 2px 6px; border-radius: 3px; }
</style>
</head>
<body>
<%= yield %>
</body>
</html>

4
config.ru Normal file
View File

@@ -0,0 +1,4 @@
require_relative "config/environment"
run Rails.application
Rails.application.load_server

11
config/application.rb Normal file
View File

@@ -0,0 +1,11 @@
require_relative "boot"
require "rails/all"
Bundler.require(*Rails.groups)
module RailsTest
class Application < Rails::Application
config.load_defaults 7.1
config.api_only = false
end
end

3
config/boot.rb Normal file
View File

@@ -0,0 +1,3 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup'
require 'bootsnap/setup'

20
config/database.yml Normal file
View File

@@ -0,0 +1,20 @@
default: &default
adapter: mysql2
encoding: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: <%= ENV.fetch("DB_USERNAME") { "root" } %>
password: <%= ENV.fetch("DB_PASSWORD") { "" } %>
host: <%= ENV.fetch("DB_HOST") { "localhost" } %>
port: <%= ENV.fetch("DB_PORT") { 3306 } %>
development:
<<: *default
database: rails_test_development
test:
<<: *default
database: rails_test_test
production:
<<: *default
database: <%= ENV.fetch("DB_NAME") { "rails_test_production" } %>

2
config/environment.rb Normal file
View File

@@ -0,0 +1,2 @@
require_relative "application"
Rails.application.initialize!

View File

@@ -0,0 +1,16 @@
require "active_support/core_ext/integer/time"
Rails.application.configure do
config.enable_reloading = false
config.eager_load = true
config.consider_all_requests_local = false
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
config.force_ssl = false
config.logger = ActiveSupport::Logger.new(STDOUT)
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
config.log_tags = [:request_id]
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
config.active_support.report_deprecations = false
config.active_record.dump_schema_after_migration = false
end

View File

@@ -0,0 +1 @@
Rails.application.config.filter_parameters += [:password, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn]

13
config/puma.rb Normal file
View File

@@ -0,0 +1,13 @@
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
port ENV.fetch("PORT") { 3000 }
environment ENV.fetch("RAILS_ENV") { "production" }
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
plugin :tmp_restart

4
config/routes.rb Normal file
View File

@@ -0,0 +1,4 @@
Rails.application.routes.draw do
root "home#index"
get "health", to: "home#health"
end

2
config/secrets.yml Normal file
View File

@@ -0,0 +1,2 @@
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>