Skip to content

Commit 6532a80

Browse files
committed
Initial commit: Create and Setup Blog Post with feedback mailer
0 parents  commit 6532a80

File tree

134 files changed

+3109
-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.

134 files changed

+3109
-0
lines changed

.dockerignore

Lines changed: 48 additions & 0 deletions
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

Lines changed: 9 additions & 0 deletions
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

Lines changed: 12 additions & 0 deletions
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

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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+
scan_js:
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Ruby
33+
uses: ruby/setup-ruby@v1
34+
with:
35+
ruby-version: .ruby-version
36+
bundler-cache: true
37+
38+
- name: Scan for security vulnerabilities in JavaScript dependencies
39+
run: bin/importmap audit
40+
41+
lint:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
47+
- name: Set up Ruby
48+
uses: ruby/setup-ruby@v1
49+
with:
50+
ruby-version: .ruby-version
51+
bundler-cache: true
52+
53+
- name: Lint code for consistent style
54+
run: bin/rubocop -f github
55+
56+
test:
57+
runs-on: ubuntu-latest
58+
59+
services:
60+
postgres:
61+
image: postgres
62+
env:
63+
POSTGRES_USER: postgres
64+
POSTGRES_PASSWORD: postgres
65+
ports:
66+
- 5432:5432
67+
options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3
68+
69+
# redis:
70+
# image: redis
71+
# ports:
72+
# - 6379:6379
73+
# options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
74+
75+
steps:
76+
- name: Install packages
77+
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libvips postgresql-client
78+
79+
- name: Checkout code
80+
uses: actions/checkout@v4
81+
82+
- name: Set up Ruby
83+
uses: ruby/setup-ruby@v1
84+
with:
85+
ruby-version: .ruby-version
86+
bundler-cache: true
87+
88+
- name: Run tests
89+
env:
90+
RAILS_ENV: test
91+
DATABASE_URL: postgres://postgres:postgres@localhost:5432
92+
# REDIS_URL: redis://localhost:6379/0
93+
run: bin/rails db:test:prepare test test:system
94+
95+
- name: Keep screenshots from failed system tests
96+
uses: actions/upload-artifact@v4
97+
if: failure()
98+
with:
99+
name: screenshots
100+
path: ${{ github.workspace }}/tmp/screenshots
101+
if-no-files-found: ignore

.gitignore

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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+
*.rbc
8+
capybara-*.html
9+
.rspec
10+
/db/*.sqlite3
11+
/db/*.sqlite3-journal
12+
/db/*.sqlite3-[0-9]*
13+
/public/system
14+
/coverage/
15+
/spec/tmp
16+
*.orig
17+
rerun.txt
18+
pickle-email-*.html
19+
20+
# Ignore bundler config.
21+
/.bundle
22+
/vendor/bundle
23+
24+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
25+
.rvmrc
26+
27+
# if using bower-rails ignore default bower_components path bower.json files
28+
/vendor/assets/bower_components
29+
*.bowerrc
30+
bower.json
31+
32+
# Ignore all environment files (except templates).
33+
/.env*
34+
!/.env*.erb
35+
36+
# Environment and secrets files
37+
config/local_env.yml
38+
39+
# Ignore pow environment settings
40+
.powenv
41+
42+
# Ignore all logfiles and tempfiles.
43+
/log/*
44+
/tmp/*
45+
!/log/.keep
46+
!/tmp/.keep
47+
48+
# Ignore pidfiles, but keep the directory.
49+
/tmp/pids/*
50+
!/tmp/pids/
51+
!/tmp/pids/.keep
52+
53+
# Ignore storage (uploaded files in development and any SQLite databases).
54+
/storage/*
55+
!/storage/.keep
56+
/tmp/storage/*
57+
!/tmp/storage/
58+
!/tmp/storage/.keep
59+
60+
/public/assets
61+
62+
# Ignore master key for decrypting credentials and more.
63+
config/initializers/secret_token.rb
64+
/config/master.key
65+
66+
# Ignore Byebug command history file.
67+
.byebug_history
68+
69+
# Ignore node_modules
70+
node_modules/
71+
72+
# Ignore precompiled javascript packs
73+
/public/packs
74+
/public/packs-test
75+
/public/assets
76+
77+
# Ignore yarn files
78+
/yarn-error.log
79+
yarn-debug.log*
80+
.yarn-integrity
81+
82+
# Ignore uploaded files in development
83+
/storage/*
84+
!/storage/.keep
85+
/public/uploads
86+
*.sqlite3-shm
87+
*.sqlite3-wal

.rubocop.yml

Lines changed: 8 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ruby-3.1.2

2

Whitespace-only changes.

Dockerfile

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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.1.2
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 postgresql-client && \
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
29+
RUN apt-get update -qq && \
30+
apt-get install --no-install-recommends -y build-essential git libpq-dev pkg-config && \
31+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
32+
33+
# Install application gems
34+
COPY Gemfile Gemfile.lock ./
35+
RUN bundle install && \
36+
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
37+
bundle exec bootsnap precompile --gemfile
38+
39+
# Copy application code
40+
COPY . .
41+
42+
# Precompile bootsnap code for faster boot times
43+
RUN bundle exec bootsnap precompile app/ lib/
44+
45+
# Adjust binfiles to be executable on Linux
46+
RUN chmod +x bin/* && \
47+
sed -i "s/\r$//g" bin/* && \
48+
sed -i 's/ruby\.exe$/ruby/' bin/*
49+
50+
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
51+
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
52+
53+
54+
55+
56+
# Final stage for app image
57+
FROM base
58+
59+
# Copy built artifacts: gems, application
60+
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
61+
COPY --from=build /rails /rails
62+
63+
# Run and own only the runtime files as a non-root user for security
64+
RUN groupadd --system --gid 1000 rails && \
65+
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
66+
chown -R rails:rails db log storage tmp
67+
USER 1000:1000
68+
69+
# Entrypoint prepares the database.
70+
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
71+
72+
# Start the server by default, this can be overwritten at runtime
73+
EXPOSE 3000
74+
CMD ["./bin/rails", "server"]

0 commit comments

Comments
 (0)