If you're using Dokku - especially for commercial purposes - consider donating to project development via OpenCollective or Patreon. Funds go to general development, support, and infrastructure costs.
If you'd like to sponsor specific functionality, see the project's Sponsoring document.
If you need support for a version of Dokku that is more than a year old, your issue may be closed without an answer. Please upgrade to a recent version before filing an issue.
Description of problem
Failed to connect Rails app to postgresql while deploy via Gitlab Pipelines. But It work correctly on git push on local machine.
Please help me find solution.
GitHub Pipeline log
Running with gitlab-runner 16.3.0~beta.108.g2b6048b4 (2b6048b4)
on green-5.saas-linux-small-amd64.runners-manager.gitlab.com/default xS6Vzpvo, system ID: s_6b1e4f06fcfd
feature flags: FF_USE_IMPROVED_URL_MASKING:true, FF_RESOLVE_FULL_TLS_CHAIN:false
Preparing the "docker+machine" executor
00:05
Using Docker executor with image dokku/ci-docker-image ...
Pulling docker image dokku/ci-docker-image ...
Using docker image sha256:39b1b48fc10c7d58c0b6ef041e9a37821c6df75b351889f87e755bd702f08f3b for dokku/ci-docker-image with digest dokku/ci-docker-image@sha256:8e9d0242dc84e35e82b4312c6c2bc7cc191e2cb362ab756978851c2a8d91cae5 ...
Preparing environment
00:01
Running on runner-xs6vzpvo-project-44243440-concurrent-0 via runner-xs6vzpvo-s-l-s-amd64-1695480759-71fa0a3b...
Getting source from Git repository
00:01
Fetching changes...
Initialized empty Git repository in /builds/gpt-beaver/gpt-rails/.git/
Created fresh repository.
Checking out 30fa8b1e as detached HEAD (ref is main)...
Skipping Git submodules setup
$ git remote set-url origin "${CI_REPOSITORY_URL}"
Restoring cache
00:05
Checking cache for gpt-rails-production-protected...
Downloading cache from https://storage.googleapis.com/gitlab-com-runners-cache/project/44243440/gpt-rails-production-protected
Successfully extracted cache
Executing "step_script" stage of the job script
07:57
Using docker image sha256:39b1b48fc10c7d58c0b6ef041e9a37821c6df75b351889f87e755bd702f08f3b for dokku/ci-docker-image with digest dokku/ci-docker-image@sha256:8e9d0242dc84e35e82b4312c6c2bc7cc191e2cb362ab756978851c2a8d91cae5 ...
$ dokku-deploy
Setting up SSH Key
Generating SSH_HOST_KEY from ssh-keyscan against 13.50.103.93:22
# 13.50.103.93:22 SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.9
# 13.50.103.93:22 SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.9
# 13.50.103.93:22 SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.9
# 13.50.103.93:22 SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.9
# 13.50.103.93:22 SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.9
Adding SSH Key to ssh-agent
Agent pid 32
Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)
Pushing to Dokku Host
remote: -----> Cleaning up...
remote: -----> Building gpt from herokuish
remote: -----> Adding BUILD_ENV to build environment...
remote: BUILD_ENV added successfully
remote: -----> Ruby app detected
remote: -----> Installing bundler 2.3.25
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-3.2.2
remote: -----> Installing dependencies using bundler 2.3.25
remote: Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
remote: Using rake 13.0.6
remote: Using concurrent-ruby 1.2.2
remote: Using i18n 1.14.1
remote: Using minitest 5.20.0
remote: Using tzinfo 2.0.6
remote: Using activesupport 7.0.8
remote: Using builder 3.2.4
remote: Using erubi 1.12.0
remote: Using racc 1.7.1
remote: Using nokogiri 1.15.4 (x86_64-linux)
remote: Using rails-dom-testing 2.2.0
remote: Using crass 1.0.6
remote: Using loofah 2.21.3
remote: Using rails-html-sanitizer 1.6.0
remote: Using actionview 7.0.8
remote: Using rack 2.2.8
remote: Using rack-test 2.1.0
remote: Using actionpack 7.0.8
remote: Using nio4r 2.5.9
remote: Using websocket-extensions 0.1.5
remote: Using websocket-driver 0.7.6
remote: Using actioncable 7.0.8
remote: Using globalid 1.2.1
remote: Using activejob 7.0.8
remote: Using activemodel 7.0.8
remote: Using activerecord 7.0.8
remote: Using marcel 1.0.2
remote: Using mini_mime 1.1.5
remote: Using activestorage 7.0.8
remote: Using date 3.3.3
remote: Using timeout 0.4.0
remote: Using net-protocol 0.2.1
remote: Using net-imap 0.3.7
remote: Using net-pop 0.1.2
remote: Using net-smtp 0.3.3
remote: Using mail 2.8.1
remote: Using actionmailbox 7.0.8
remote: Using actionmailer 7.0.8
remote: Using actiontext 7.0.8
remote: Using public_suffix 5.0.3
remote: Using addressable 2.8.5
remote: Using baran 0.1.8
remote: Using bcrypt 3.1.19
remote: Using msgpack 1.7.2
remote: Using bootsnap 1.16.0
remote: Using bundler 2.4.10
remote: Using colorize 0.8.1
remote: Using connection_pool 2.4.1
remote: Using zeitwerk 2.6.11
remote: Using dry-core 1.0.1
remote: Using dry-inflector 1.0.0
remote: Using dry-logic 1.5.0
remote: Using dry-types 1.7.1
remote: Using ice_nine 0.11.2
remote: Using dry-struct 1.6.0
remote: Using faraday-net_http 3.0.2
remote: Using ruby2_keywords 0.0.5
remote: Using faraday 2.7.10
remote: Using multipart-post 2.3.0
remote: Using faraday-multipart 1.0.4
remote: Using httpclient 2.8.3
remote: Using method_source 1.0.0
remote: Using thor 1.2.2
remote: Using railties 7.0.8
remote: Using importmap-rails 1.2.1
remote: Using json-schema 4.0.0
remote: Using tiktoken_ruby 0.0.5 (x86_64-linux)
remote: Using langchainrb 0.6.14
remote: Using pg 1.5.3
remote: Using puma 6.3.1
remote: Using rails 7.0.8
remote: Using redis-client 0.17.0
remote: Using redis 5.0.7
remote: Using rollbar 3.4.0
remote: Using ruby-openai 5.1.0
remote: Using sidekiq 7.1.4
remote: Using sprockets 4.2.0
remote: Using sprockets-rails 3.4.2
remote: Using tailwindcss-rails 2.0.30 (x86_64-linux)
remote: Using telegram-bot 0.15.7 from https://github.com/telegram-bot-rb/telegram-bot.git
remote: Using telegram-bot-types 0.7.0
remote: Bundle complete! 25 Gemfile dependencies, 81 gems now installed.
remote: Gems in the groups 'development' and 'test' were not installed.
remote: Bundled gems are installed into `./vendor/bundle`
remote: Bundle completed (4.15s)
remote: Cleaning up the bundler cache.
remote: Removing bundler (2.3.25)
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote:
remote: Rebuilding...
remote:
remote: Done in 883ms.
remote: Asset precompilation completed (4.37s)
remote: Cleaning assets
remote: Running: rake assets:clean
remote: -----> Detecting rails configuration
remote:
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> web, worker
remote: -----> Releasing gpt...
remote: -----> Checking for predeploy task
remote: No predeploy task found, skipping
remote: -----> Checking for release task
remote: No release task found, skipping
remote: =====> Processing deployment checks
remote: No CHECKS file found. Simple container checks will be performed.
remote: For more efficient zero downtime deployments, create a CHECKS file. See https://dokku.com/docs/deployment/zero-downtime-deploys/ for xamples
remote: -----> Deploying gpt via the docker-local scheduler...
remote: -----> Deploying web (count=1)
remote: Attempting pre-flight checks (web.1)
remote: -----> Executing 1 healthchecks
remote: Running healthcheck name='default' type='uptime' uptime=10
remote: Healthcheck succeeded name='default'
remote: All checks successful (web.1)
remote: =====> Start of gpt container output (web.1)
remote: [12] Puma starting in cluster mode...
remote: [12] * Puma version: 6.3.1 (ruby 3.2.2-p53) ("Mugi No Toki Itaru")
remote: [12] * Min threads: 5
remote: [12] * Max threads: 5
remote: [12] * Environment: production
remote: [12] * Master PID: 12
remote: [12] * Workers: 2
remote: [12] * Restarts: (✔) hot (✔) phased
remote: [12] * Listening on http://0.0.0.0:5000
remote: [12] Use Ctrl-C to stop
remote: [12] - Worker 0 (PID: 151) booted in 4.62s, phase: 0
remote: [12] - Worker 1 (PID: 153) booted in 4.63s, phase: 0
remote: =====> End of gpt container output (web.1)
remote: Scheduling old container shutdown in 60 seconds (web.1)
remote: =====> Triggering early nginx proxy rebuild
remote: -----> Ensuring network configuration is in sync for gpt
remote: -----> Configuring gpt.gpt-api.itbeaver.co...(using built-in template)
remote: -----> Creating http nginx.conf
remote: Reloading nginx
remote: -----> Deploying worker (count=0)
remote: -----> Running post-deploy
remote: ! Detected IPv4 domain name with nginx proxy enabled.
remote: ! Ensure the default nginx site is removed before continuing.
remote: -----> Ensuring network configuration is in sync for gpt
remote: -----> Configuring gpt.gpt-api.itbeaver.co...(using built-in template)
remote: -----> Creating http nginx.conf
remote: Reloading nginx
remote: -----> Renaming containers
remote: Found previous container(s) (6b62b146dde0) named gpt.web.1
remote: Renaming container (6b62b146dde0) gpt.web.1 to gpt.web.1.1695481307
remote: Renaming container gpt.web.1.upcoming-19970 (62c7cf85318e) to gpt.web.1
remote: -----> Checking for postdeploy task
remote: -----> Executing postdeploy task from app.json: RAILS_ENV=production bundle exec rake db:migrate; RAILS_ENV=production bundle exec rails b:seed
remote: =====> Start of gpt postdeploy task (24ea18495) output
remote: ! rake aborted!
remote: ! ActiveRecord::ConnectionNotEstablished: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or irectory
remote: ! Is the server running locally and accepting connections on that socket?
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/postgresql_adapter.rb:87:in `rescue in ew_client'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/postgresql_adapter.rb:77:in new_client'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in postgresql_connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in public_send'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in new_connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:700:in checkout_new_connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:679:in try_to_checkout_new_connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:640:in acquire_connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:341:in checkout'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_handler.rb:211:in retrieve_connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_handling.rb:313:in `retrieve_connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_handling.rb:280:in `connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/railties/databases.rake:92:in `block (2 levels) in main>'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
remote: ! /app/bin/bundle:108:in `load'
remote: ! /app/bin/bundle:108:in `<main>'
remote: ! Caused by:
remote: ! PG::ConnectionBad: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
remote: ! Is the server running locally and accepting connections on that socket?
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/pg-1.5.3/lib/pg/connection.rb:819:in `connect_start'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/pg-1.5.3/lib/pg/connection.rb:819:in `connect_to_hosts'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/pg-1.5.3/lib/pg/connection.rb:759:in `new'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/pg-1.5.3/lib/pg.rb:63:in `connect'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/postgresql_adapter.rb:78:in new_client'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in postgresql_connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in public_send'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in new_connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:700:in checkout_new_connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:679:in try_to_checkout_new_connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:640:in acquire_connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:341:in checkout'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_handler.rb:211:in retrieve_connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_handling.rb:313:in `retrieve_connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_handling.rb:280:in `connection'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/railties/databases.rake:92:in `block (2 levels) in main>'
remote: ! /app/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
remote: ! /app/bin/bundle:108:in `load'
remote: ! /app/bin/bundle:108:in `<main>'
remote: ! Tasks: TOP => db:migrate
remote: ! (See full trace by running task with --trace)
remote: =====> End of gpt postdeploy task (24ea18495) output
remote: ! Execution of postdeploy task failed: RAILS_ENV=production bundle exec rake db:migrate; RAILS_ENV=production bundle exec rails b:seed
To ssh://13.50.103.93:22/gpt
! [remote rejected] 30fa8b1eb6dfb9bd36b9d2c4319bf7fa64dc0dc8 -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://13.50.103.93:22/gpt'
Running after_script
00:03
Running after script...
$ dokku-unlock
Setting up SSH Key
Generating SSH_HOST_KEY from ssh-keyscan against 13.50.103.93:22
# 13.50.103.93:22 SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.9
# 13.50.103.93:22 SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.9
# 13.50.103.93:22 SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.9
# 13.50.103.93:22 SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.9
# 13.50.103.93:22 SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.9
Adding SSH Key to ssh-agent
Agent pid 32
Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)
Unlocking Dokku deployment
! Unable to remove deploy lock
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1
Description of problem
Failed to connect Rails app to postgresql while deploy via Gitlab Pipelines. But It work correctly on git push on local machine.
Please help me find solution.
GitHub Pipeline log
Environment Information
dokku report APP_NAME
output