Created
February 4, 2025 19:41
-
-
Save stephaneliu/4e460403a4a2dd61181e9f037240bad0 to your computer and use it in GitHub Desktop.
Kamal deploy.yml for PSQL
This file contains hidden or 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
# Name of your application. Used to uniquely configure containers. | |
service: hcr_kamal | |
# Name of the container image. | |
image: stephaneliu/hcr_kamal_pg | |
# Deploy to these servers. | |
servers: | |
web: | |
- kamal.hawaiiancrane.com | |
# job: | |
# hosts: | |
# - 192.168.0.1 | |
# cmd: bin/jobs | |
# Enable SSL auto certification via Let's Encrypt and allow for multiple apps on a single web server. | |
# Remove this section when using multiple web servers and ensure you terminate SSL at your load balancer. | |
# | |
# Note: If using Cloudflare, set encryption mode in SSL/TLS setting to "Full" to enable CF-to-app encryption. | |
proxy: | |
ssl: true | |
host: kamal.hawaiiancrane.com | |
# Credentials for your image host. | |
registry: | |
# Specify the registry server, if you're not using Docker Hub | |
# server: registry.digitalocean.com / ghcr.io / ... | |
username: stephaneliu | |
# Always use an access token rather than real password when possible. | |
password: | |
- KAMAL_REGISTRY_PASSWORD | |
# Inject ENV variables into containers (secrets come from .kamal/secrets). | |
env: | |
secret: | |
- RAILS_MASTER_KEY | |
- POSTGRES_PASSWORD | |
clear: | |
# Run the Solid Queue Supervisor inside the web server's Puma process to do jobs. | |
# When you start using multiple servers, you should split out job processing to a dedicated machine. | |
SOLID_QUEUE_IN_PUMA: true | |
# Set number of processes dedicated to Solid Queue (default: 1) | |
# JOB_CONCURRENCY: 3 | |
# Set number of cores available to the application on each server (default: 1). | |
# WEB_CONCURRENCY: 2 | |
# Match this to any external database server to configure Active Record correctly | |
# Use hcr_kamal-db for a db accessory server on same machine via local kamal docker network. | |
DB_HOST: hcr_kamal-db | |
POSTGRES_USER: hcr_kamal | |
POSTGRES_DB: hcr_kamal_production | |
# Log everything from Rails | |
RAILS_LOG_LEVEL: debug | |
# Aliases are triggered with "bin/kamal <alias>". You can overwrite arguments on invocation: | |
# "bin/kamal logs -r job" will tail logs from the first server in the job section. | |
aliases: | |
console: app exec --interactive --reuse "bin/rails console" | |
shell: app exec --interactive --reuse "bash" | |
logs: app logs -f | |
dbc: app exec --interactive --reuse "bin/rails dbconsole" | |
# Use a persistent storage volume for sqlite database files and local Active Storage files. | |
# Recommended to change this to a mounted volume path that is backed up off server. | |
volumes: | |
- "hcr_kamal_storage:/rails/storage" | |
# Bridge fingerprinted assets, like JS and CSS, between versions to avoid | |
# hitting 404 on in-flight requests. Combines all files from new and old | |
# version inside the asset_path. | |
asset_path: /rails/public/assets | |
# Configure the image builder. | |
builder: | |
arch: amd64 | |
# # Build image via remote server (useful for faster amd64 builds on arm64 computers) | |
# remote: ssh://docker@docker-builder-server | |
# | |
# # Pass arguments and secrets to the Docker build process | |
# args: | |
# RUBY_VERSION: ruby-3.3.6 | |
# secrets: | |
# - GITHUB_TOKEN | |
# - RAILS_MASTER_KEY | |
# Use a different ssh user than root | |
# ssh: | |
# user: app | |
# Use accessory services (secrets come from .kamal/secrets). | |
accessories: | |
db: | |
image: postgres:17.2 | |
host: kamal.hawaiiancrane.com | |
port: 5432 | |
env: | |
clear: | |
DB_HOST: hcr_kamal-db | |
POSTGRES_USER: hcr_kamal | |
POSTGRES_DB: hcr_kamal_production | |
secret: | |
- POSTGRES_PASSWORD | |
files: | |
- db/production.sql:/docker-entrypoint-initdb.d/setup.sql | |
directories: | |
- data:/var/lib/postgres/data | |
# redis: | |
# image: redis:7.0 | |
# host: 192.168.0.2 | |
# port: 6379 | |
# directories: | |
# - data:/data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment