Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
/tmp/pids/*
!/tmp/pids/.keep

# Ignore the Postgres bind mount created by the compose db service. It is
# root-owned, so a rebuild after first boot cannot read the build context.
/data

# Ignore storage (uploaded files in development and any SQLite databases).
/storage/*
!/storage/.keep
Expand Down
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ POSTGRES_DB=streamvault
# Host port to expose the app on (container always listens on 80).
PORT=3000

# ── TLS ──────────────────────────────────────────────────────────
# Both default to true, which is correct when a TLS-terminating proxy
# sits in front of the app. Set both to false only when it is reached
# directly over plain HTTP on a trusted network (LAN, tailnet, VPN).
FORCE_SSL=true
Comment thread
vitobotta marked this conversation as resolved.
Resolved
Comment thread
vitobotta marked this conversation as resolved.
Resolved
ASSUME_SSL=true

# ── External APIs ────────────────────────────────────────────────
# Torrentio API base URL. Default is the public instance, but it may
# be blocked by Cloudflare. Consider running a self-hosted proxy
Expand Down
7 changes: 5 additions & 2 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@
# Assume all access to the app is happening through a SSL-terminating
# reverse proxy (Caddy / kamal-proxy), so request.ssl? reflects the
# upstream scheme even though Rails sees plain HTTP on the socket.
config.assume_ssl = true
# Set ASSUME_SSL=false when Rails is reached directly instead.
config.assume_ssl = ActiveModel::Type::Boolean.new.cast(ENV.fetch("ASSUME_SSL", "true")) != false

# Force all access over SSL, set HSTS, and mark cookies secure. The
# app carries session cookies and RealDebrid API keys in requests, so
# transport encryption is required end-to-end.
config.force_ssl = true
# Set FORCE_SSL=false to serve plain HTTP on a trusted network (a LAN,
# a tailnet, or the container's published port) with no TLS terminator.
config.force_ssl = ActiveModel::Type::Boolean.new.cast(ENV.fetch("FORCE_SSL", "true")) != false

# Skip http-to-https redirect for the default health check endpoint.
config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
Expand Down
6 changes: 5 additions & 1 deletion config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
plugin :tmp_restart

# Run the Solid Queue supervisor inside of Puma for single-server deployments.
plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"]
# Compare the value rather than testing the variable for presence: every
# string is truthy, so SOLID_QUEUE_IN_PUMA=false would otherwise start the
# supervisor even when a separate worker container owns job execution.
solid_queue_in_puma = ENV.fetch("SOLID_QUEUE_IN_PUMA", "").strip.downcase
plugin :solid_queue unless %w[0 false no off].include?(solid_queue_in_puma)
Comment thread
vitobotta marked this conversation as resolved.
Resolved

# Specify the PID file. Defaults to tmp/pids/server.pid in development.
# In other environments, only set the PID file if requested.
Expand Down
25 changes: 24 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,30 @@ services:
environment:
RAILS_ENV: production
DATABASE_URL: postgres://${POSTGRES_USER:-streamvault}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB:-streamvault}
SOLID_QUEUE_IN_PUMA: "true"
# Background jobs run in the `worker` service below, so the web
# container must not start its own Solid Queue supervisor.
SOLID_QUEUE_IN_PUMA: "false"
# Both default to true, which is right behind a TLS-terminating proxy.
# Set both to false in .env to serve plain HTTP on a trusted network.
FORCE_SSL: "${FORCE_SSL:-true}"
ASSUME_SSL: "${ASSUME_SSL:-true}"
depends_on:
db:
condition: service_healthy
restart: unless-stopped

# Runs the Solid Queue supervisor, dispatcher and workers. The image's
# default command is the web server, so the command override is required.
worker:
build:
context: .
env_file: .env
environment:
RAILS_ENV: production
DATABASE_URL: postgres://${POSTGRES_USER:-streamvault}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB:-streamvault}
# Threads per worker process; see config/queue.yml.
JOB_CONCURRENCY: "${JOB_CONCURRENCY:-1}"
Comment thread
vitobotta marked this conversation as resolved.
Resolved
command: [ "bundle", "exec", "bin/jobs" ]
Comment thread
vitobotta marked this conversation as resolved.
Resolved
depends_on:
db:
condition: service_healthy
Expand Down