Postgres

Example Pipeline with Postgres

Example Yaml configuration for a project requiring a Postgres as a pipeline dependency.

Scenario

User is looking to create a pipeline that can integrate with an ephemeral Postgres instance.

Services

Services Yaml block can be used with stages and steps pipelines. This example uses a basic steps configuration.

The following pipeline concepts are being used in the pipeline below:

version: "1"
services:
  - name: postgres
    image: postgres:latest
    pull: always
    environment:
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: password
      POSTGRES_DB: vela

steps:
  - name: check status
    image: postgres:latest
    pull: always
    environment:
      PGPASSWORD=password
    commands:
      # sleeping can help ensure the service adequate time to start
      - sleep 15
      - psql -U admin -d vela -h postgres -p 5432

Detach

If you’re looking for more granular start time for the container you can add a detach flag within stages and steps pipelines.

The following pipeline concepts are being used in the pipeline below:

version: "1"

steps:
  - name: postgres
    image: postgres:latest
    pull: always
    environment:
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: password
      POSTGRES_DB: vela    
    detach: true

  - name: check status
    image: postgres:latest
    pull: always
    environment:
      PGPASSWORD=password
    commands:
      # sleeping can help ensure the service adequate time to start
      - sleep 15
      - psql -U admin -d vela -h postgres -p 5432