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.

43 lines
1.2 KiB

4 months ago
kind: pipeline
type: docker
name: deploy-postgresql
services:
- name: postgresql
image: postgres:13
4 months ago
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 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:
# 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:
# Commande pour afficher les logs du conteneur PostgreSQL
- docker logs postgresql || echo "Failed to retrieve PostgreSQL logs."