-
Notifications
You must be signed in to change notification settings - Fork 0
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 a5e4b77
Showing
104 changed files
with
2,524 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,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* |
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,5 @@ | ||
<%# This env template should lookup values from a password store or from ENV -%> | ||
# Generated by kamal envify from .env.erb | ||
KAMAL_REGISTRY_PASSWORD=<%= ENV["KAMAL_REGISTRY_PASSWORD"] %> | ||
RAILS_MASTER_KEY=<%= File.read("config/master.key") %> | ||
# GITHUB_TOKEN=<%#= `gh config get -h github.com oauth_token`.strip %> |
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: daily | ||
open-pull-requests-limit: 10 | ||
- package-ecosystem: github-actions | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
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,90 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
scan_ruby: | ||
runs-on: ubuntu-latest | ||
|
||
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 common Rails security vulnerabilities using static analysis | ||
run: bin/brakeman --no-pager | ||
|
||
scan_js: | ||
runs-on: ubuntu-latest | ||
|
||
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 | ||
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 | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
|
||
# services: | ||
# 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 libjemalloc2 libvips sqlite3 | ||
|
||
- 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 | ||
env: | ||
RAILS_ENV: test | ||
# REDIS_URL: redis://localhost:6379/0 | ||
run: bin/rails db:test:prepare test test:system | ||
|
||
- 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,38 @@ | ||
# 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 | ||
|
||
# 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,13 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# A sample docker-setup hook | ||
# | ||
# Sets up a Docker network on defined hosts which can then be used by the application’s containers | ||
|
||
hosts = ENV["KAMAL_HOSTS"].split(",") | ||
|
||
hosts.each do |ip| | ||
destination = "root@#{ip}" | ||
puts "Creating a Docker network \"kamal\" on #{destination}" | ||
`ssh #{destination} docker network create kamal` | ||
end |
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,14 @@ | ||
#!/bin/sh | ||
|
||
# A sample post-deploy hook | ||
# | ||
# These environment variables are available: | ||
# KAMAL_RECORDED_AT | ||
# KAMAL_PERFORMER | ||
# KAMAL_VERSION | ||
# KAMAL_HOSTS | ||
# KAMAL_ROLE (if set) | ||
# KAMAL_DESTINATION (if set) | ||
# KAMAL_RUNTIME | ||
|
||
echo "$KAMAL_PERFORMER deployed $KAMAL_VERSION to $KAMAL_DESTINATION in $KAMAL_RUNTIME seconds" |
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 @@ | ||
#!/bin/sh | ||
|
||
echo "Rebooted Traefik on $KAMAL_HOSTS" |
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,51 @@ | ||
#!/bin/sh | ||
|
||
# A sample pre-build hook | ||
# | ||
# Checks: | ||
# 1. We have a clean checkout | ||
# 2. A remote is configured | ||
# 3. The branch has been pushed to the remote | ||
# 4. The version we are deploying matches the remote | ||
# | ||
# These environment variables are available: | ||
# KAMAL_RECORDED_AT | ||
# KAMAL_PERFORMER | ||
# KAMAL_VERSION | ||
# KAMAL_HOSTS | ||
# KAMAL_ROLE (if set) | ||
# KAMAL_DESTINATION (if set) | ||
|
||
if [ -n "$(git status --porcelain)" ]; then | ||
echo "Git checkout is not clean, aborting..." >&2 | ||
git status --porcelain >&2 | ||
exit 1 | ||
fi | ||
|
||
first_remote=$(git remote) | ||
|
||
if [ -z "$first_remote" ]; then | ||
echo "No git remote set, aborting..." >&2 | ||
exit 1 | ||
fi | ||
|
||
current_branch=$(git branch --show-current) | ||
|
||
if [ -z "$current_branch" ]; then | ||
echo "Not on a git branch, aborting..." >&2 | ||
exit 1 | ||
fi | ||
|
||
remote_head=$(git ls-remote $first_remote --tags $current_branch | cut -f1) | ||
|
||
if [ -z "$remote_head" ]; then | ||
echo "Branch not pushed to remote, aborting..." >&2 | ||
exit 1 | ||
fi | ||
|
||
if [ "$KAMAL_VERSION" != "$remote_head" ]; then | ||
echo "Version ($KAMAL_VERSION) does not match remote HEAD ($remote_head), aborting..." >&2 | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
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,47 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# A sample pre-connect check | ||
# | ||
# Warms DNS before connecting to hosts in parallel | ||
# | ||
# These environment variables are available: | ||
# KAMAL_RECORDED_AT | ||
# KAMAL_PERFORMER | ||
# KAMAL_VERSION | ||
# KAMAL_HOSTS | ||
# KAMAL_ROLE (if set) | ||
# KAMAL_DESTINATION (if set) | ||
# KAMAL_RUNTIME | ||
|
||
hosts = ENV["KAMAL_HOSTS"].split(",") | ||
results = nil | ||
max = 3 | ||
|
||
elapsed = Benchmark.realtime do | ||
results = hosts.map do |host| | ||
Thread.new do | ||
tries = 1 | ||
|
||
begin | ||
Socket.getaddrinfo(host, 0, Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME) | ||
rescue SocketError | ||
if tries < max | ||
puts "Retrying DNS warmup: #{host}" | ||
tries += 1 | ||
sleep rand | ||
retry | ||
else | ||
puts "DNS warmup failed: #{host}" | ||
host | ||
end | ||
end | ||
|
||
tries | ||
end | ||
end.map(&:value) | ||
end | ||
|
||
retries = results.sum - hosts.size | ||
nopes = results.count { |r| r == max } | ||
|
||
puts "Prewarmed %d DNS lookups in %.2f sec: %d retries, %d failures" % [ hosts.size, elapsed, retries, nopes ] |
Oops, something went wrong.