2017-04-20 1 views
3

내의 bitbucket - pipelines.yml 설정 파일입니다 액세스 : 나는 psql를 사용하여 원하는처럼 데이터베이스를 초기화하고 싶은의 Bitbucket 파이프 라인 - 다른 컨테이너 여기

# This is a sample build configuration for Javascript. 
# Check our guides at https://confluence.atlassian.com/x/VYk8Lw for more examples. 
# Only use spaces to indent your .yml configuration. 
# ----- 
# You can specify a custom docker image from Docker Hub as your build environment. 
image: node:6.9.5 

pipelines: 
    default: 
    - step: 
     script: 
      # Step 1 : Install yarn with the easy way : https://yarnpkg.com/en/docs/install#alternatives-tab 
      - curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.22.0 
      # Step 2: Belived https://confluence.atlassian.com/bitbucket/javascript-node-js-with-bitbucket-pipelines-873891287.html#Javascript(Node.js)withBitbucketPipelines-ManagingdependencieswithYarn 
      # PATH variable should change like they said 
      - export PATH=$HOME/.yarn/bin:$PATH 
      # Step 3: Install app dependencies 
      - yarn install 
      #Allow to test app in production context 
      - export NODE_ENV=production 
      #Allow to specify the JWT TOKEN Signature (and not use OAuth0) 
      - export SECRET_SIGNATURE_JWT_TOKEN=pokémon47 
      # prepare PostgreSQL 
      # - psql -U "postgres" -c "CREATE DATABASE custom_db" # create a new database 
      # - psql -U "postgres" -c "CREATE USER custom_user WITH PASSWORD 'custom_pass'" # create a new user : custom_user 
      # - psql -U "postgres" -d "custom_db" -f sql/database_tables.sql # create tables 
      # - psql -U "postgres" -d "custom_db" -f sql/database_grant.sql # give him the credentials 
      # - psql -U "postgres" -d "custom_db" -f sql/test_insert.sql # add basic data inside the database : some parkings and reasons 
      #run the test with database 
      - npm test 
     services: 
      - postgres 

definitions: 
    services: 
    postgres: 
     image: postgres:9.3 

가. 유일한 문제 : 어떻게 컨테이너에 액세스 할 수 있습니까?

은 내가 고정 표시기에 대해 알고있는 고전 명령을 시도 :

docker ps 

docker exec -it myContainer bash 

결과 :

Cannot connect to the Docker daemon. Is the docker daemon running on this host? 

을 (그리고 나는이 CI에 고정 표시기 데몬을 가능하게 할 권리가 없음) 사용 설명서 : https://confluence.atlassian.com/bitbucket/use-services-and-databases-in-bitbucket-pipelines-874786688.htmlhttps://confluence.atlassian.com/bitbucket/test-with-databases-in-bitbucket-pipelines-856697462.html#TestwithdatabasesinBitbucketPipelines-PostgreSQL -defaultuser

PS :

The files belonging to this database system will be owned by user "postgres". 
This user must also own the server process. 

The database cluster will be initialized with locale "en_US.utf8". 
The default database encoding has accordingly been set to "UTF8". 
The default text search configuration will be set to "english". 

Data page checksums are disabled. 

fixing permissions on existing directory /var/lib/postgresql/data ... ok 
creating subdirectories ... ok 
selecting default max_connections ... 100 
selecting default shared_buffers ... 128MB 
creating configuration files ... ok 
creating template1 database in /var/lib/postgresql/data/base/1 ... ok 
initializing pg_authid ... ok 
initializing dependencies ... ok 
creating system views ... ok 
loading system objects' descriptions ... ok 
creating collations ... ok 
creating conversions ... ok 
creating dictionaries ... ok 
setting privileges on built-in objects ... ok 
creating information schema ... ok 
loading PL/pgSQL server-side language ... ok 
vacuuming database template1 ... ok 
copying template1 to template0 ... ok 
copying template1 to postgres ... ok 

WARNING: enabling "trust" authentication for local connections 
You can change this by editing pg_hba.conf or using the option -A, or 
--auth-local and --auth-host, the next time you run initdb. 
syncing data to disk ... ok 

Success. You can now start the database server using: 

    postgres -D /var/lib/postgresql/data 
or 
    pg_ctl -D /var/lib/postgresql/data -l logfile start 

**************************************************** 
WARNING: No password has been set for the database. 
     This will allow anyone with access to the 
     Postgres port to access your database. In 
     Docker's default configuration, this is 
     effectively any other container on the same 
     system. 

     Use "-e POSTGRES_PASSWORD=password" to set 
     it in "docker run". 
**************************************************** 
waiting for server to start....LOG: database system was shut down at 2017-04-20 12:50:43 UTC 
LOG: MultiXact member wraparound protections are now enabled 
LOG: autovacuum launcher started 
LOG: database system is ready to accept connections 
done 
server started 
ALTER ROLE 


/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/* 

LOG: received fast shutdown request 
LOG: aborting any active transactions 
waiting for server to shut down...LOG: autovacuum launcher shutting down 
LOG: shutting down 
.LOG: database system is shut down 
done 
server stopped 

PostgreSQL init process complete; ready for start up. 

LOG: database system was shut down at 2017-04-20 12:50:45 UTC 
LOG: MultiXact member wraparound protections are now enabled 
LOG: database system is ready to accept connections 
LOG: autovacuum launcher started 
LOG: received smart shutdown request 
LOG: autovacuum launcher shutting down 
LOG: shutting down 
LOG: database system is shut down 

답변

0

의 Bitbucket의 문서가 명확하게하려고하지만 사용자 도우려고하지 않습니다 :

PostgreSQL의 로컬 호스트에 사용할 수 있습니다 당신은 PostgreSQL을 컨테이너에서 로그를 원하는 경우 : 5432

문제는 psql이 예상대로 작동하지 않습니다. 기본 동작은 파일 소켓 (/var/run/postgresql/.s.PGSQL.5432)에 연결하는 것이고 localhost에는 연결하지 않습니다.

연결할 호스트 매개 변수를 설정해야합니다. psql -h localhost

관련 문제