Skip to content

Commit 725c49b

Browse files
committed
base
0 parents  commit 725c49b

File tree

98 files changed

+2897
-0
lines changed

Some content is hidden

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

98 files changed

+2897
-0
lines changed

.devcontainer/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
2+
ARG RUBY_VERSION=3.3.4
3+
FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION

.devcontainer/compose.yaml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: "example"
2+
3+
services:
4+
rails-app:
5+
build:
6+
context: ..
7+
dockerfile: .devcontainer/Dockerfile
8+
9+
volumes:
10+
- ../..:/workspaces:cached
11+
12+
# Overrides default command so things don't shut down after the process ends.
13+
command: sleep infinity
14+
15+
# Uncomment the next line to use a non-root user for all processes.
16+
# user: vscode
17+
18+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
19+
# (Adding the "ports" property to this file will not forward from a Codespace.)
20+
depends_on:
21+
- redis
22+
23+
redis:
24+
image: redis:7.2
25+
restart: unless-stopped
26+
volumes:
27+
- redis-data:/data
28+
29+
30+
volumes:
31+
redis-data:

.devcontainer/devcontainer.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby
3+
{
4+
"name": "example",
5+
"dockerComposeFile": "compose.yaml",
6+
"service": "rails-app",
7+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
8+
9+
// Features to add to the dev container. More info: https://containers.dev/features.
10+
"features": {
11+
"ghcr.io/devcontainers/features/github-cli:1": {},
12+
"ghcr.io/rails/devcontainer/features/activestorage": {},
13+
"ghcr.io/devcontainers/features/node:1": {},
14+
"ghcr.io/rails/devcontainer/features/sqlite3": {}
15+
},
16+
17+
"containerEnv": {
18+
"REDIS_URL": "redis://redis:6379/1"
19+
},
20+
21+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
22+
"forwardPorts": [3000, 6379],
23+
24+
// Configure tool-specific properties.
25+
// "customizations": {},
26+
27+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
28+
// "remoteUser": "root",
29+
30+
31+
// Use 'postCreateCommand' to run commands after the container is created.
32+
"postCreateCommand": "bin/setup"
33+
}

.dockerignore

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
2+
3+
# Ignore git directory.
4+
/.git/
5+
/.gitignore
6+
7+
# Ignore bundler config.
8+
/.bundle
9+
10+
# Ignore all environment files (except templates).
11+
/.env*
12+
!/.env*.erb
13+
14+
# Ignore all default key files.
15+
/config/master.key
16+
/config/credentials/*.key
17+
18+
# Ignore all logfiles and tempfiles.
19+
/log/*
20+
/tmp/*
21+
!/log/.keep
22+
!/tmp/.keep
23+
24+
# Ignore pidfiles, but keep the directory.
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/.keep
33+
34+
# Ignore assets.
35+
/node_modules/
36+
/app/assets/builds/*
37+
!/app/assets/builds/.keep
38+
/public/assets
39+
40+
# Ignore CI service files.
41+
/.github
42+
43+
# Ignore development files
44+
/.devcontainer
45+
46+
# Ignore Docker-related files
47+
/.dockerignore
48+
/Dockerfile*

.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

.github/dependabot.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: bundler
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 10
8+
- package-ecosystem: github-actions
9+
directory: "/"
10+
schedule:
11+
interval: daily
12+
open-pull-requests-limit: 10

.github/workflows/ci.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [ main ]
7+
8+
jobs:
9+
scan_ruby:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Ruby
17+
uses: ruby/setup-ruby@v1
18+
with:
19+
ruby-version: .ruby-version
20+
bundler-cache: true
21+
22+
- name: Scan for common Rails security vulnerabilities using static analysis
23+
run: bin/brakeman --no-pager
24+
25+
lint:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Set up Ruby
32+
uses: ruby/setup-ruby@v1
33+
with:
34+
ruby-version: .ruby-version
35+
bundler-cache: true
36+
37+
- name: Lint code for consistent style
38+
run: bin/rubocop -f github
39+

.gitignore

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
2+
#
3+
# Temporary files generated by your text editor or operating system
4+
# belong in git's global ignore instead:
5+
# `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore`
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
36+
37+
/app/assets/builds/*
38+
!/app/assets/builds/.keep
39+
40+
/node_modules

.node-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
21.7.3

.rubocop.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Omakase Ruby styling for Rails
2+
inherit_gem: { rubocop-rails-omakase: rubocop.yml }
3+
4+
# Overwrite or add rules to create your own house style
5+
#
6+
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
7+
# Layout/SpaceInsideArrayLiteralBrackets:
8+
# Enabled: false

.ruby-version

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

Dockerfile

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# syntax = docker/dockerfile:1
2+
3+
# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand:
4+
# docker build -t my-app .
5+
# docker run -d -p 80:80 -p 443:443 --name my-app -e RAILS_MASTER_KEY=<value from config/master.key> my-app
6+
7+
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
8+
ARG RUBY_VERSION=3.3.4
9+
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
10+
11+
# Rails app lives here
12+
WORKDIR /rails
13+
14+
# Install base packages
15+
RUN apt-get update -qq && \
16+
apt-get install --no-install-recommends -y curl libjemalloc2 libvips sqlite3 && \
17+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
18+
19+
# Set production environment
20+
ENV RAILS_ENV="production" \
21+
BUNDLE_DEPLOYMENT="1" \
22+
BUNDLE_PATH="/usr/local/bundle" \
23+
BUNDLE_WITHOUT="development"
24+
25+
# Throw-away build stage to reduce size of final image
26+
FROM base AS build
27+
28+
# Install packages needed to build gems and node modules
29+
RUN apt-get update -qq && \
30+
apt-get install --no-install-recommends -y build-essential git node-gyp pkg-config python-is-python3 && \
31+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
32+
33+
# Install JavaScript dependencies
34+
ARG NODE_VERSION=21.7.3
35+
ARG YARN_VERSION=1.22.22
36+
ENV PATH=/usr/local/node/bin:$PATH
37+
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
38+
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
39+
npm install -g yarn@$YARN_VERSION && \
40+
rm -rf /tmp/node-build-master
41+
42+
# Install application gems
43+
COPY Gemfile Gemfile.lock ./
44+
RUN bundle install && \
45+
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
46+
bundle exec bootsnap precompile --gemfile
47+
48+
# Install node modules
49+
COPY package.json yarn.lock ./
50+
RUN yarn install --frozen-lockfile
51+
52+
# Copy application code
53+
COPY . .
54+
55+
# Precompile bootsnap code for faster boot times
56+
RUN bundle exec bootsnap precompile app/ lib/
57+
58+
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
59+
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
60+
61+
62+
RUN rm -rf node_modules
63+
64+
65+
# Final stage for app image
66+
FROM base
67+
68+
# Copy built artifacts: gems, application
69+
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
70+
COPY --from=build /rails /rails
71+
72+
# Run and own only the runtime files as a non-root user for security
73+
RUN groupadd --system --gid 1000 rails && \
74+
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
75+
chown -R rails:rails db log storage tmp
76+
USER 1000:1000
77+
78+
# Entrypoint prepares the database.
79+
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
80+
81+
# Start the server by default, this can be overwritten at runtime
82+
EXPOSE 3000
83+
CMD ["./bin/rails", "server"]

Gemfile

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
source "https://rubygems.org"
2+
3+
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
4+
gem "rails", "~> 7.2.1"
5+
# The modern asset pipeline for Rails [https://github.com/rails/propshaft]
6+
gem "propshaft"
7+
# Use sqlite3 as the database for Active Record
8+
gem "sqlite3", ">= 1.4"
9+
# Use the Puma web server [https://github.com/puma/puma]
10+
gem "puma", ">= 5.0"
11+
# Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
12+
gem "jsbundling-rails"
13+
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
14+
gem "turbo-rails"
15+
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
16+
gem "stimulus-rails"
17+
# Bundle and process CSS [https://github.com/rails/cssbundling-rails]
18+
gem "cssbundling-rails"
19+
# Use Redis adapter to run Action Cable in production
20+
gem "redis", ">= 4.0.1"
21+
22+
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
23+
# gem "kredis"
24+
25+
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
26+
# gem "bcrypt", "~> 3.1.7"
27+
28+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
29+
30+
# Reduces boot times through caching; required in config/boot.rb
31+
gem "bootsnap", require: false
32+
33+
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
34+
# gem "image_processing", "~> 1.2"
35+
36+
group :development, :test do
37+
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
38+
gem "debug", platforms: %i[ mri windows ], require: "debug/prelude"
39+
40+
# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
41+
gem "brakeman", require: false
42+
43+
# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
44+
gem "rubocop-rails-omakase", require: false
45+
end
46+
47+
group :development do
48+
# Use console on exceptions pages [https://github.com/rails/web-console]
49+
gem "web-console"
50+
end

0 commit comments

Comments
 (0)