You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
kind: pipeline
|
|
type: docker
|
|
name: deploy-postgresql
|
|
|
|
services:
|
|
- name: postgresql
|
|
image: postgres:13
|
|
environment:
|
|
POSTGRES_USER:
|
|
from_secret: db_user
|
|
POSTGRES_PASSWORD:
|
|
from_secret: db_password
|
|
POSTGRES_DB:
|
|
from_secret: db_database
|
|
|
|
steps:
|
|
- name: wait-for-postgresql
|
|
image: busybox
|
|
commands:
|
|
- sleep 60 # Donne du temps au conteneur PostgreSQL pour démarrer
|
|
|
|
- name: check-database
|
|
image: postgres:13
|
|
environment:
|
|
POSTGRES_USER:
|
|
from_secret: db_user
|
|
POSTGRES_PASSWORD:
|
|
from_secret: db_password
|
|
POSTGRES_DB:
|
|
from_secret: db_database
|
|
commands:
|
|
# Essaie de se connecter au service PostgreSQL en utilisant le nom du service
|
|
- psql -h postgresql -U $POSTGRES_USER -d $POSTGRES_DB -c "SELECT 1;" || echo "Failed to connect using 'postgresql', trying localhost..."
|
|
|
|
# Si cela échoue, essaie de se connecter via localhost
|
|
- psql -h localhost -U $POSTGRES_USER -d $POSTGRES_DB -c "SELECT 1;" || echo "Failed to connect using localhost."
|