-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7ea424f
Showing
98 changed files
with
2,762 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version | ||
ARG RUBY_VERSION=3.1.3 | ||
FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
services: | ||
rails-app: | ||
build: | ||
context: .. | ||
dockerfile: .devcontainer/Dockerfile | ||
|
||
volumes: | ||
- ../..:/workspaces:cached | ||
|
||
# Overrides default command so things don't shut down after the process ends. | ||
command: sleep infinity | ||
|
||
networks: | ||
- default | ||
|
||
# Uncomment the next line to use a non-root user for all processes. | ||
# user: vscode | ||
|
||
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally. | ||
# (Adding the "ports" property to this file will not forward from a Codespace.) | ||
ports: | ||
- 45678:45678 | ||
depends_on: | ||
- selenium | ||
- redis | ||
- postgres | ||
|
||
selenium: | ||
image: seleniarm/standalone-chromium | ||
restart: unless-stopped | ||
networks: | ||
- default | ||
|
||
redis: | ||
image: redis:7.2 | ||
restart: unless-stopped | ||
networks: | ||
- default | ||
volumes: | ||
- redis-data:/data | ||
|
||
postgres: | ||
image: postgres:16.1 | ||
restart: unless-stopped | ||
networks: | ||
- default | ||
volumes: | ||
- postgres-data:/var/lib/postgresql/data | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
|
||
|
||
volumes: | ||
redis-data: | ||
postgres-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby | ||
{ | ||
"name": "maybe_marketing", | ||
"dockerComposeFile": "compose.yaml", | ||
"service": "rails-app", | ||
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
"features": { | ||
"ghcr.io/devcontainers/features/github-cli:1": {}, | ||
"ghcr.io/rails/devcontainer/features/activestorage": {}, | ||
"ghcr.io/rails/devcontainer/features/postgres-client": {} | ||
}, | ||
|
||
"containerEnv": { | ||
"CAPYBARA_SERVER_PORT": "45678", | ||
"SELENIUM_HOST": "selenium", | ||
"REDIS_URL": "redis://redis:6379/1", | ||
"DB_HOST": "postgres" | ||
}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
"forwardPorts": [3000, 5432, 6379], | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root", | ||
|
||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "bin/setup" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files. | ||
|
||
# Ignore git directory. | ||
/.git/ | ||
/.gitignore | ||
|
||
# Ignore bundler config. | ||
/.bundle | ||
|
||
# Ignore all environment files (except templates). | ||
/.env* | ||
!/.env*.erb | ||
|
||
# Ignore all default key files. | ||
/config/master.key | ||
/config/credentials/*.key | ||
|
||
# Ignore all logfiles and tempfiles. | ||
/log/* | ||
/tmp/* | ||
!/log/.keep | ||
!/tmp/.keep | ||
|
||
# Ignore pidfiles, but keep the directory. | ||
/tmp/pids/* | ||
!/tmp/pids/.keep | ||
|
||
# Ignore storage (uploaded files in development and any SQLite databases). | ||
/storage/* | ||
!/storage/.keep | ||
/tmp/storage/* | ||
!/tmp/storage/.keep | ||
|
||
# Ignore assets. | ||
/node_modules/ | ||
/app/assets/builds/* | ||
!/app/assets/builds/.keep | ||
/public/assets | ||
|
||
# Ignore CI service files. | ||
/.github | ||
|
||
# Ignore development files | ||
/.devcontainer | ||
|
||
# Ignore Docker-related files | ||
/.dockerignore | ||
/Dockerfile* |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# See https://git-scm.com/docs/gitattributes for more about git attribute files. | ||
|
||
# Mark the database schema as having been generated. | ||
db/schema.rb linguist-generated | ||
|
||
# Mark any vendored files as having been vendored. | ||
vendor/* linguist-vendored | ||
config/credentials/*.yml.enc diff=rails_credentials | ||
config/credentials.yml.enc diff=rails_credentials |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: bundler | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
open-pull-requests-limit: 10 | ||
- package-ecosystem: github-actions | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
open-pull-requests-limit: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
scan_ruby: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: .ruby-version | ||
bundler-cache: true | ||
|
||
- name: Scan for security vulnerabilities in Ruby dependencies | ||
run: bin/brakeman --no-pager | ||
|
||
scan_js: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: .ruby-version | ||
bundler-cache: true | ||
|
||
- name: Scan for security vulnerabilities in JavaScript dependencies | ||
run: bin/importmap audit | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: .ruby-version | ||
bundler-cache: true | ||
|
||
- name: Lint code for consistent style | ||
run: bin/rubocop -f github | ||
|
||
- name: Lint templates for consistent style | ||
run: ./bin/erblint ./app/**/*.erb | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
|
||
services: | ||
postgres: | ||
image: postgres | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
ports: | ||
- 5432:5432 | ||
options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
||
# redis: | ||
# image: redis | ||
# ports: | ||
# - 6379:6379 | ||
# options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 | ||
|
||
steps: | ||
- name: Install packages | ||
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libvips postgresql-client libpq-dev | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: .ruby-version | ||
bundler-cache: true | ||
|
||
- name: Run tests and smoke test seed | ||
env: | ||
RAILS_ENV: test | ||
DATABASE_URL: postgres://postgres:postgres@localhost:5432 | ||
# REDIS_URL: redis://localhost:6379/0 | ||
run: | | ||
bin/rails db:create | ||
bin/rails db:schema:load | ||
bin/rails test:all | ||
bin/rails db:seed | ||
- name: Keep screenshots from failed system tests | ||
uses: actions/upload-artifact@v4 | ||
if: failure() | ||
with: | ||
name: screenshots | ||
path: ${{ github.workspace }}/tmp/screenshots | ||
if-no-files-found: ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# See https://help.github.com/articles/ignoring-files for more about ignoring files. | ||
# | ||
# Temporary files generated by your text editor or operating system | ||
# belong in git's global ignore instead: | ||
# `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore` | ||
|
||
# Ignore bundler config. | ||
/.bundle | ||
|
||
# Ignore all environment files (except templates). | ||
/.env* | ||
!/.env*.erb | ||
!/.env.example | ||
|
||
# Ignore all logfiles and tempfiles. | ||
/log/* | ||
/tmp/* | ||
!/log/.keep | ||
!/tmp/.keep | ||
|
||
# Ignore pidfiles, but keep the directory. | ||
/tmp/pids/* | ||
!/tmp/pids/ | ||
!/tmp/pids/.keep | ||
|
||
# Ignore storage (uploaded files in development and any SQLite databases). | ||
/storage/* | ||
!/storage/.keep | ||
/tmp/storage/* | ||
!/tmp/storage/ | ||
!/tmp/storage/.keep | ||
|
||
/public/assets | ||
|
||
# Ignore master key for decrypting credentials and more. | ||
/config/master.key | ||
|
||
/app/assets/builds/* | ||
!/app/assets/builds/.keep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Omakase Ruby styling for Rails | ||
inherit_gem: { rubocop-rails-omakase: rubocop.yml } | ||
|
||
# Overwrite or add rules to create your own house style | ||
# | ||
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]` | ||
# Layout/SpaceInsideArrayLiteralBrackets: | ||
# Enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.1.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# syntax = docker/dockerfile:1 | ||
|
||
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version | ||
ARG RUBY_VERSION=3.1.3 | ||
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base | ||
|
||
# Rails app lives here | ||
WORKDIR /rails | ||
|
||
# Install base packages | ||
RUN apt-get update -qq && \ | ||
apt-get install --no-install-recommends -y curl libjemalloc2 libvips postgresql-client | ||
|
||
# Set production environment | ||
ENV RAILS_ENV="production" \ | ||
BUNDLE_DEPLOYMENT="1" \ | ||
BUNDLE_PATH="/usr/local/bundle" \ | ||
BUNDLE_WITHOUT="development" | ||
|
||
# Throw-away build stage to reduce size of final image | ||
FROM base as build | ||
|
||
# Install packages needed to build gems | ||
RUN apt-get install --no-install-recommends -y build-essential git libpq-dev pkg-config | ||
|
||
# Install application gems | ||
COPY Gemfile Gemfile.lock ./ | ||
RUN bundle install && \ | ||
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \ | ||
bundle exec bootsnap precompile --gemfile | ||
|
||
# Copy application code | ||
COPY . . | ||
|
||
# Precompile bootsnap code for faster boot times | ||
RUN bundle exec bootsnap precompile app/ lib/ | ||
|
||
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY | ||
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile | ||
|
||
|
||
|
||
|
||
# Final stage for app image | ||
FROM base | ||
|
||
# Clean up installation packages to reduce image size | ||
RUN rm -rf /var/lib/apt/lists /var/cache/apt/archives | ||
|
||
# Copy built artifacts: gems, application | ||
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}" | ||
COPY --from=build /rails /rails | ||
|
||
# Run and own only the runtime files as a non-root user for security | ||
RUN groupadd --system --gid 1000 rails && \ | ||
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \ | ||
chown -R rails:rails db log storage tmp | ||
USER 1000:1000 | ||
|
||
# Entrypoint prepares the database. | ||
ENTRYPOINT ["/rails/bin/docker-entrypoint"] | ||
|
||
# Start the server by default, this can be overwritten at runtime | ||
EXPOSE 3000 | ||
CMD ["./bin/rails", "server"] |
Oops, something went wrong.