When running kamal setup
using Rails 8 with Kamal v2, I run into the error:
Running docker exec kamal-proxy kamal-proxy deploy .........
ERROR bin/rails aborted!
ActiveRecord::AdapterNotSpecified: database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
Tasks: TOP => db:prepare => db:load_config
(See full trace by running task with --trace)
bin/rails aborted!
.... repeats error several times...
...
Finished all in 70.3 seconds
RROR (SSHKit::Command::Failed): Exception while executing on host 192.168.1.106: docker exit status: 1
docker stdout: Nothing written
docker stderr: Error: target failed to become healthy
The postgres container is been setup along with others
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ca123123d01d postgres:16.2 "docker-entrypoint.s…" 8 hours ago Exited (255) 7 hours ago liveactivity-db
Any ideas on how to resolve the issue with the adapter not been found would be great!
deploy.yml
service: liveactivity
image: my_image
servers:
web:
- 192.168.1.106
registry:
username: my_username
password:
- KAMAL_REGISTRY_PASSWORD
env:
secret:
- RAILS_MASTER_KEY
clear:
SOLID_QUEUE_IN_PUMA: true
DB_HOST: 192.168.1.106
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"
volumes:
- "liveactivity_storage:/rails/storage"
asset_path: /rails/public/assets
builder:
arch: arm64
ssh:
user: my_ssh_username
proxy: my_ssh_username@192.168.1.106
keys: ["~/.ssh/id_rsa"]
accessories:
db:
image: postgres:16.2
host: 192.168.1.106
port: 5432
env:
clear:
POSTGRES_USER: "postgres"
POSTGRES_DB: "liveactivity_production"
secret:
- POSTGRES_PASSWORD
directories:
- data:/var/lib/postgresql/data
database.yml
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
production:
primary: &primary_production
<<: *default
host: <%= ENV["DB_HOST"] %>
database: <%= ENV["POSTGRES_DB"] %>
username: <%= ENV["POSTGRES_USER"] %>
password: <%= ENV["POSTGRES_PASSWORD"] %>
cache:
<<: *primary_production
database: liveactivity_production_cache
migrations_paths: db/cache_migrate
queue:
<<: *primary_production
database: liveactivity_production_queue
migrations_paths: db/queue_migrate
cable:
<<: *primary_production
database: liveactivity_production_cable
migrations_paths: db/cable_migrate
Any changes made to config/deploy.yml, config/database.yml or .kamal/secrets that have not been committed to git before running kamal setup/deploy are ignored. It's actually showing in the output when running kamal setup:
Building from a local git clone, so ignoring these uncommitted changes:
M .kamal/secrets
M config/database.yml
M config/deploy.yml
Once I committed my changes, removed the containers from the server, and ran kamal setup again the error was resolved.