0

CircleCi 1.0からCircleCi 2.0への移行中です。ここに私のcircle.ymlファイルがどのように見えるかです:CircleCi 2.0ビルドでpsqlコマンドを使用

version: 2 
environment: 
    TZ: "/usr/share/zoneinfo/America/Los_Angeles" 

jobs: 
    build: 
    working_directory: ~/circleci-dashboard 
    docker: 
     - image: circleci/ruby:2.3-node 
     environment: 
      PGHOST: 127.0.0.1 
      PGUSER: ubuntu 
      RAILS_ENV: test 
     - image: circleci/postgres:9.6-alpine 
     environment: 
      POSTGRES_USER: ubuntu 
      POSTGRES_DB: circle_test 
      POSTGRES_PASSWORD: "" 
    steps: 
     - checkout 

     - run: 
      name: 'CircleCI dependencies' 
      command: bash deploy/circle-dependencies.sh 

     # Restore bundle cache 
     - type: cache-restore 
     key: dashboard-{{ checksum "Gemfile.lock" }} 

     # Bundle install dependencies 
     - run: bundle install --path vendor/bundle 

     # Store bundle cache 
     - type: cache-save 
     key: dashboard-{{ checksum "Gemfile.lock" }} 
     paths: 
      - vendor/bundle 

     # Add the Postgres 9.6 binaries to the path. 
     - run: echo '/usr/lib/postgresql/9.6/bin/:$PATH' >> $BASH_ENV 

     - run: sudo apt install postgresql-client 

     - run: 
      name: Set up Survey Builder database 
      command: sudo psql -p 5433 -c 'create database survey_builder_test' 

     - run: 
      name: Set up database 
      command: | 
      bundle exec rake db:create db:schema:load --trace 
      environment: 
      DATABASE_URL: "postgres://[email protected]:5432/circle_test" 

私は、このコマンドに問題があります。

- run: 
     name: Set up Survey Builder database 
     command: sudo psql -p 5432 -c 'create database survey_builder_test' 

をし、それが次のエラーを返します。

#!/bin/bash -eo pipefail 
sudo psql -p 5432 -c 'create database survey_builder_test' 

psql: could not connect to server: No such file or directory 
    Is the server running locally and accepting 
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? 
Exited with code 2 

任意のヒントを歓迎いたします?

+0

答えがあなたのために機能しましたか? – Gerep

+0

私は今日それをチェックして、あなたに知らせるでしょう。 –

答えて

0

コマンドsudo psql -p 5433 -c 'create database survey_builder_test'は、それがpostgresql-clientをインストールするために必要とされた理由です、画像circleci/ruby:2.3-node上で実行されているが、また起動するPostgresのサービスを待つために必要であり、そのために、私はこの使用しています:

- run: 
      name: Waiting for PostgreSQL to start 
      command: | 
      for i in `seq 1 10`; 
      do 
       nc -z localhost 5432 && echo Success && exit 0 
       echo -n . 
       sleep 2 
      done 
      echo Failed waiting for Postgres && exit 1 
関連する問題