2017-04-20 11 views
3

hier ist meine bitbucket-pipelines.yml Konfigurationsdatei:Bitbucket Pipelines - Zugang zu einem anderen Behälter

# 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 

Ich mag würde die Datenbank initialisieren, wie ich mit psql will. Das einzige Problem: Wie kann ich auf den Container zugreifen?

habe ich versucht, die klassischen Befehle Ich weiß, für Docker:

docker ps 

docker exec -it myContainer bash 

Ergebnis:

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

(Und ich habe kein Recht, die Docker-Daemon auf diesem CI zu aktivieren)

Die Dokumentation, die ich verwendete: https://confluence.atlassian.com/bitbucket/use-services-and-databases-in-bitbucket-pipelines-874786688.html und https://confluence.atlassian.com/bitbucket/test-with-databases-in-bitbucket-pipelines-856697462.html#TestwithdatabasesinBitbucketPipelines-PostgreSQL -defaultuser

PS: Wenn Sie die Protokolle von Postgresql Container wollen:

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 

Antwort

0

Bitbucket docs versuchen klar zu sein, aber es nicht versucht, den Benutzer zu helfen:

PostgreSQL auf localhost zur Verfügung: 5432

Das Problem ist, funktioniert psql nicht wie erwartet. Ihr Standardverhalten ist die Verbindung mit dem Datei-Socket (/var/run/postgresql/.s.PGSQL.5432), nicht mit localhost.

Sie müssen den Hostparameter für die Verbindung festlegen: psql -h localhost

Verwandte Themen