Skip to content

Commit 07cf85e

Browse files
committed
Initial commit
0 parents  commit 07cf85e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1140
-0
lines changed

.dockerignore

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 environment files (except templates).
10+
/.env*
11+
!/.env*.erb
12+
13+
# Ignore all default key files.
14+
/config/master.key
15+
/config/credentials/*.key
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/.keep
26+
27+
# Ignore storage (uploaded files in development and any SQLite databases).
28+
/storage/*
29+
!/storage/.keep
30+
/tmp/storage/*
31+
!/tmp/storage/.keep
32+
33+
# Ignore assets.
34+
/node_modules/
35+
/app/assets/builds/*
36+
!/app/assets/builds/.keep
37+
/public/assets

.gitattributes

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# See https://git-scm.com/docs/gitattributes for more about git attribute files.
2+
3+
# Mark the database schema as having been generated.
4+
db/schema.rb linguist-generated
5+
6+
# Mark any vendored files as having been vendored.
7+
vendor/* linguist-vendored
8+
config/credentials/*.yml.enc diff=rails_credentials
9+
config/credentials.yml.enc diff=rails_credentials

.gitignore

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
2+
#
3+
# If you find yourself ignoring temporary files generated by your text editor
4+
# or operating system, you probably want to add a global ignore instead:
5+
# git config --global core.excludesfile '~/.gitignore_global'
6+
7+
# Ignore bundler config.
8+
/.bundle
9+
10+
# Ignore all environment files (except templates).
11+
/.env*
12+
!/.env*.erb
13+
14+
# Ignore all logfiles and tempfiles.
15+
/log/*
16+
/tmp/*
17+
!/log/.keep
18+
!/tmp/.keep
19+
20+
# Ignore pidfiles, but keep the directory.
21+
/tmp/pids/*
22+
!/tmp/pids/
23+
!/tmp/pids/.keep
24+
25+
# Ignore storage (uploaded files in development and any SQLite databases).
26+
/storage/*
27+
!/storage/.keep
28+
/tmp/storage/*
29+
!/tmp/storage/
30+
!/tmp/storage/.keep
31+
32+
/public/assets
33+
34+
# Ignore master key for decrypting credentials and more.
35+
/config/master.key

.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ruby-3.2.2

Dockerfile

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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.2.2
5+
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
6+
7+
# Rails app lives here
8+
WORKDIR /rails
9+
10+
# Set production environment
11+
ENV RAILS_ENV="production" \
12+
BUNDLE_DEPLOYMENT="1" \
13+
BUNDLE_PATH="/usr/local/bundle" \
14+
BUNDLE_WITHOUT="development"
15+
16+
17+
# Throw-away build stage to reduce size of final image
18+
FROM base as build
19+
20+
# Install packages needed to build gems
21+
RUN apt-get update -qq && \
22+
apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config
23+
24+
# Install application gems
25+
COPY Gemfile Gemfile.lock ./
26+
RUN bundle install && \
27+
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
28+
bundle exec bootsnap precompile --gemfile
29+
30+
# Copy application code
31+
COPY . .
32+
33+
# Precompile bootsnap code for faster boot times
34+
RUN bundle exec bootsnap precompile app/ lib/
35+
36+
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
37+
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
38+
39+
40+
# Final stage for app image
41+
FROM base
42+
43+
# Install packages needed for deployment
44+
RUN apt-get update -qq && \
45+
apt-get install --no-install-recommends -y curl libvips postgresql-client && \
46+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
47+
48+
# Copy built artifacts: gems, application
49+
COPY --from=build /usr/local/bundle /usr/local/bundle
50+
COPY --from=build /rails /rails
51+
52+
# Run and own only the runtime files as a non-root user for security
53+
RUN useradd rails --create-home --shell /bin/bash && \
54+
chown -R rails:rails db log storage tmp
55+
USER rails:rails
56+
57+
# Entrypoint prepares the database.
58+
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
59+
60+
# Start the server by default, this can be overwritten at runtime
61+
EXPOSE 3000
62+
CMD ["./bin/rails", "server"]

Gemfile

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
source "https://rubygems.org"
2+
3+
ruby "3.2.2"
4+
5+
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
6+
gem "rails", "~> 7.1.2"
7+
8+
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
9+
gem "sprockets-rails"
10+
11+
# Use postgresql as the database for Active Record
12+
gem "pg", "~> 1.1"
13+
14+
# Use the Puma web server [https://github.com/puma/puma]
15+
gem "puma", ">= 5.0"
16+
17+
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
18+
gem "importmap-rails"
19+
20+
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
21+
gem "turbo-rails"
22+
23+
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
24+
gem "stimulus-rails"
25+
26+
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
27+
gem "jbuilder"
28+
29+
# Use Redis adapter to run Action Cable in production
30+
# gem "redis", ">= 4.0.1"
31+
32+
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
33+
# gem "kredis"
34+
35+
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
36+
# gem "bcrypt", "~> 3.1.7"
37+
38+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
39+
gem "tzinfo-data", platforms: %i[ windows jruby ]
40+
41+
# Reduces boot times through caching; required in config/boot.rb
42+
gem "bootsnap", require: false
43+
44+
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
45+
# gem "image_processing", "~> 1.2"
46+
47+
group :development, :test do
48+
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
49+
gem "debug", platforms: %i[ mri windows ]
50+
end
51+
52+
group :development do
53+
# Use console on exceptions pages [https://github.com/rails/web-console]
54+
gem "web-console"
55+
56+
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
57+
# gem "rack-mini-profiler"
58+
59+
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
60+
# gem "spring"
61+
end
62+

README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# README
2+
3+
This README would normally document whatever steps are necessary to get the
4+
application up and running.
5+
6+
Things you may want to cover:
7+
8+
* Ruby version
9+
10+
* System dependencies
11+
12+
* Configuration
13+
14+
* Database creation
15+
16+
* Database initialization
17+
18+
* How to run the test suite
19+
20+
* Services (job queues, cache servers, search engines, etc.)
21+
22+
* Deployment instructions
23+
24+
* ...

Rakefile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Add your own tasks in files placed in lib/tasks ending in .rake,
2+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3+
4+
require_relative "config/application"
5+
6+
Rails.application.load_tasks

app/assets/config/manifest.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//= link_tree ../images
2+
//= link_directory ../stylesheets .css

app/assets/images/.keep

Whitespace-only changes.
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* This is a manifest file that'll be compiled into application.css, which will include all the files
3+
* listed below.
4+
*
5+
* Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
6+
* vendor/assets/stylesheets directory can be referenced here using a relative path.
7+
*
8+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
9+
* compiled file so the styles you add here take precedence over styles defined in any other CSS
10+
* files in this directory. Styles in this file should be added after the last require_* statement.
11+
* It is generally better to create a new file per style scope.
12+
*
13+
*= require_tree .
14+
*= require_self
15+
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module ApplicationCable
2+
class Channel < ActionCable::Channel::Base
3+
end
4+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module ApplicationCable
2+
class Connection < ActionCable::Connection::Base
3+
end
4+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class ApplicationController < ActionController::Base
2+
end

app/controllers/concerns/.keep

Whitespace-only changes.

app/helpers/application_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ApplicationHelper
2+
end

app/jobs/application_job.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class ApplicationJob < ActiveJob::Base
2+
# Automatically retry jobs that encountered a deadlock
3+
# retry_on ActiveRecord::Deadlocked
4+
5+
# Most jobs are safe to ignore if the underlying records are no longer available
6+
# discard_on ActiveJob::DeserializationError
7+
end

app/mailers/application_mailer.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class ApplicationMailer < ActionMailer::Base
2+
default from: "[email protected]"
3+
layout "mailer"
4+
end

app/models/application_record.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class ApplicationRecord < ActiveRecord::Base
2+
primary_abstract_class
3+
end

app/models/concerns/.keep

Whitespace-only changes.
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>RailsAppTest6</title>
5+
<meta name="viewport" content="width=device-width,initial-scale=1">
6+
<%= csrf_meta_tags %>
7+
<%= csp_meta_tag %>
8+
9+
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
10+
</head>
11+
12+
<body>
13+
<%= yield %>
14+
</body>
15+
</html>

app/views/layouts/mailer.html.erb

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5+
<style>
6+
/* Email styles need to be inline */
7+
</style>
8+
</head>
9+
10+
<body>
11+
<%= yield %>
12+
</body>
13+
</html>

app/views/layouts/mailer.text.erb

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= yield %>

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 [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then
5+
./bin/rails db:prepare
6+
fi
7+
8+
exec "${@}"

bin/rails

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env ruby
2+
APP_PATH = File.expand_path("../config/application", __dir__)
3+
require_relative "../config/boot"
4+
require "rails/commands"

bin/rake

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env ruby
2+
require_relative "../config/boot"
3+
require "rake"
4+
Rake.application.run

bin/setup

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env ruby
2+
require "fileutils"
3+
4+
# path to your application root.
5+
APP_ROOT = File.expand_path("..", __dir__)
6+
7+
def system!(*args)
8+
system(*args, exception: true)
9+
end
10+
11+
FileUtils.chdir APP_ROOT do
12+
# This script is a way to set up or update your development environment automatically.
13+
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
14+
# Add necessary setup steps to this file.
15+
16+
puts "== Installing dependencies =="
17+
system! "gem install bundler --conservative"
18+
system("bundle check") || system!("bundle install")
19+
20+
# puts "\n== Copying sample files =="
21+
# unless File.exist?("config/database.yml")
22+
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
23+
# end
24+
25+
puts "\n== Preparing database =="
26+
system! "bin/rails db:prepare"
27+
28+
puts "\n== Removing old logs and tempfiles =="
29+
system! "bin/rails log:clear tmp:clear"
30+
31+
puts "\n== Restarting application server =="
32+
system! "bin/rails restart"
33+
end

config.ru

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This file is used by Rack-based servers to start the application.
2+
3+
require_relative "config/environment"
4+
5+
run Rails.application
6+
Rails.application.load_server

0 commit comments

Comments
 (0)