Skip to content

Commit

Permalink
Coolify!
Browse files Browse the repository at this point in the history
  • Loading branch information
northeastprince committed Jan 14, 2025
1 parent e941cda commit 9cd703f
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 234 deletions.
10 changes: 0 additions & 10 deletions .env.erb

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/cd.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
# Environment variables
.env*
!.env*example
!.env.erb

# IDEs
.idea
Expand Down
3 changes: 0 additions & 3 deletions .kamal/hooks/post-deploy

This file was deleted.

9 changes: 0 additions & 9 deletions .kamal/secrets

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ENV RAILS_ENV="production" \
FROM base AS build

RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git libvips pkg-config sqlite3
apt-get install --no-install-recommends -y build-essential git pkg-config libyaml-dev sqlite3 libvips

COPY .ruby-version Gemfile Gemfile.lock ./
RUN bundle install && \
Expand Down
10 changes: 5 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ gem "hashid-rails" # Non-sequential IDs
gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby] # Windows doesn't include zoneinfo files
gem "bootsnap", require: false # reduces boot times through caching; required in config/boot.rb

gem "kamal" # Deployments
gem "console1984"
gem "audits1984"
gem "litestream"

# Application monitoring (errors, performance, etc.)
gem "appsignal"
gem "lograge" # Log formatting
gem "lograge"

gem "console1984"
gem "audits1984"

group :development, :test do
gem "debug", platforms: %i[mri mingw x64_mingw]
Expand Down
55 changes: 27 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ GEM
aws-sigv4 (1.10.1)
aws-eventstream (~> 1, >= 1.0.2)
base64 (0.2.0)
bcrypt_pbkdf (1.1.1)
bcrypt_pbkdf (1.1.1-arm64-darwin)
benchmark (0.4.0)
better_errors (2.10.1)
erubi (>= 1.0.0)
Expand Down Expand Up @@ -194,7 +192,6 @@ GEM
dotenv (= 3.1.7)
railties (>= 6.1)
drb (2.2.1)
ed25519 (1.3.0)
erubi (1.13.1)
et-orbi (1.2.11)
tzinfo
Expand Down Expand Up @@ -255,17 +252,6 @@ GEM
activesupport (>= 5.0.0)
jmespath (1.6.2)
json (2.9.1)
kamal (2.4.0)
activesupport (>= 7.0)
base64 (~> 0.2)
bcrypt_pbkdf (~> 1.0)
concurrent-ruby (~> 1.2)
dotenv (~> 3.1)
ed25519 (~> 1.2)
net-ssh (~> 7.3)
sshkit (>= 1.23.0, < 2.0)
thor (~> 1.3)
zeitwerk (>= 2.6.18, < 3.0)
language_server-protocol (3.17.0.3)
launchy (3.0.1)
addressable (~> 2.8)
Expand All @@ -278,7 +264,32 @@ GEM
railties (>= 6.1)
rexml
lint_roller (1.1.0)
litestream (0.12.0)
actionpack (>= 7.0)
actionview (>= 7.0)
activejob (>= 7.0)
activesupport (>= 7.0)
logfmt (>= 0.0.10)
railties (>= 7.0)
sqlite3
litestream (0.12.0-arm64-darwin)
actionpack (>= 7.0)
actionview (>= 7.0)
activejob (>= 7.0)
activesupport (>= 7.0)
logfmt (>= 0.0.10)
railties (>= 7.0)
sqlite3
litestream (0.12.0-x86_64-linux)
actionpack (>= 7.0)
actionview (>= 7.0)
activejob (>= 7.0)
activesupport (>= 7.0)
logfmt (>= 0.0.10)
railties (>= 7.0)
sqlite3
local_time (3.0.2)
logfmt (0.0.10)
logger (1.6.4)
lograge (0.14.0)
actionpack (>= 4)
Expand Down Expand Up @@ -318,21 +329,15 @@ GEM
net-protocol
net-protocol (0.2.2)
timeout
net-scp (4.0.0)
net-ssh (>= 2.6.5, < 8.0.0)
net-sftp (4.0.0)
net-ssh (>= 5.0.0, < 8.0.0)
net-smtp (0.5.0)
net-protocol
net-ssh (7.3.0)
nio4r (2.7.4)
nokogiri (1.18.1-aarch64-linux-gnu)
racc (~> 1.4)
nokogiri (1.18.1-arm64-darwin)
racc (~> 1.4)
nokogiri (1.18.1-x86_64-linux-gnu)
racc (~> 1.4)
ostruct (0.6.1)
pagy (6.4.3)
parallel (1.26.3)
parser (3.3.6.0)
Expand Down Expand Up @@ -379,7 +384,7 @@ GEM
regexp_parser (2.10.0)
reline (0.6.0)
io-console (~> 0.5)
request_store (1.5.1)
request_store (1.6.0)
rack (>= 1.4)
rexml (3.3.9)
rinku (2.0.6)
Expand Down Expand Up @@ -435,12 +440,6 @@ GEM
sqlite3 (2.5.0-aarch64-linux-gnu)
sqlite3 (2.5.0-arm64-darwin)
sqlite3 (2.5.0-x86_64-linux-gnu)
sshkit (1.23.2)
base64
net-scp (>= 1.1.2)
net-sftp (>= 2.1.2)
net-ssh (>= 2.8.0)
ostruct
standard (1.43.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
Expand Down Expand Up @@ -520,8 +519,8 @@ DEPENDENCIES
image_processing (>= 1.2)
importmap-rails
jbuilder
kamal
letter_opener_web
litestream
local_time
lograge
mission_control-jobs
Expand Down
32 changes: 0 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,38 +58,6 @@ dependency installed on your machine. For macs, run:
brew install vips
```

## Production Deployment

**Vendors:**

- Hetzner
- Runs the Rails app and Solid Queue (3 vCPU, 4 GB)
- Deployed via [Kamal](https://kamal-deploy.org)

### Kamal

All pushes to the `main` branch are automatically deployed by Kamal.

- Environment variables are stored on GitHub and accessed by GitHub Actions
when deploying.
- Deployments take 2-5 minutes to complete.
- After pushing to `main`, please monitor the `CD / Deploy` check for the status
of the deployment.

### Production Rails Console

We audit the use of the production console with [`console1984`](https://github.com/basecamp/console1984)
and [`audits1984`](https://github.com/basecamp/audits1984).

To use the production console, you must first have SSH access to the Hetzner
server(s). Please ask [`@garyhtou`](https://garytou.com) for access.

Then, run the following locally on your computer:

```sh
bin/console prod
```

### Solid Queue

Solid Queue is used to process background jobs in production. In development, we use
Expand Down
47 changes: 0 additions & 47 deletions bin/console

This file was deleted.

62 changes: 0 additions & 62 deletions config/deploy.yml

This file was deleted.

2 changes: 2 additions & 0 deletions config/initializers/console1984.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Rails.application.configure do
config.console1984.ask_for_username_if_empty = true
config.console1984.incinerate = false

config.console1984.production_data_warning = <<~WARNING
You have access to production data here. That's a big deal.
To keep sensitive info safe and private, we audit the commands you type here.
Expand Down
7 changes: 7 additions & 0 deletions config/initializers/litestream.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Rails.application.configure do
aws = Rails.application.credentials.aws

config.litestream.replica_bucket = aws&.bucket
config.litestream.replica_key_id = aws&.access_key_id
config.litestream.replica_access_key = aws&.secret_access_key
end
14 changes: 7 additions & 7 deletions config/litestream.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
access-key-id: $LITESTREAM_ACCESS_KEY_ID
secret-access-key: $LITESTREAM_SECRET_ACCESS_KEY

dbs:
- path: /storage/production.sqlite3
replicas:
- url: s3://${LITESTREAM_BUCKET}/db
region: $LITESTREAM_REGION
- path: storage/production.sqlite3
replicas:
- type: s3
bucket: $LITESTREAM_REPLICA_BUCKET
path: production.sqlite3
access-key-id: $LITESTREAM_ACCESS_KEY_ID
secret-access-key: $LITESTREAM_SECRET_ACCESS_KEY
1 change: 1 addition & 0 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@
$LOAD_PATH << File.expand_path("../lib", __dir__)

plugin :dartsass if Rails.env.development?
plugin :litestream if Rails.env.production?
Loading

0 comments on commit 9cd703f

Please sign in to comment.