|
|
|
@ -1,4 +1,3 @@
|
|
|
|
|
|
|
|
|
|
kind: pipeline
|
|
|
|
|
type: docker
|
|
|
|
|
name: deploy-postgresql
|
|
|
|
@ -15,13 +14,29 @@ services:
|
|
|
|
|
from_secret: db_database
|
|
|
|
|
|
|
|
|
|
steps:
|
|
|
|
|
- name: wait-for-postgresql
|
|
|
|
|
image: busybox
|
|
|
|
|
commands:
|
|
|
|
|
- sleep 30 # 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:
|
|
|
|
|
- sleep 30 # Waiting for the database to be fully ready
|
|
|
|
|
- psql -h postgresql -U $POSTGRES_USER -d $POSTGRES_DB -c "SELECT 1;"
|
|
|
|
|
# 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;"
|
|
|
|
|
|
|
|
|
|
- name: check-postgres-logs
|
|
|
|
|
image: postgres:13
|
|
|
|
|
commands:
|
|
|
|
|
- docker logs postgresql
|
|
|
|
|
# Commande pour afficher les logs du conteneur PostgreSQL
|
|
|
|
|
- docker logs postgresql || echo "Failed to retrieve PostgreSQL logs."
|
|
|
|
|