-
Notifications
You must be signed in to change notification settings - Fork 0
⭐ StartPostgresql
StartPostgresql StartPostgresql is the provisioning action responsible for launching PostgreSQL database containers with secure defaults, persistent volumes, SSL/TLS support, engine‑specific environment variables, and predictable runtime behavior. It follows the same architectural pattern as other StartActions but implements PostgreSQL‑specific logic.
This page explains how StartPostgresql works, what it generates, and how it fits into the broader provisioning system.
Purpose of StartPostgresql The StartPostgresql action handles all logic required to start a PostgreSQL instance, including:
Validating configuration
Generating SSL certificates
Creating persistent volumes
Building environment variables
Generating Docker Compose
Applying PostgreSQL‑specific runtime settings
Configuring healthchecks
Starting the container
It ensures PostgreSQL is provisioned consistently and securely across all deployments.
PostgreSQL‑Specific Requirements PostgreSQL has several engine‑specific requirements that differ from MySQL, Redis, and other engines:
-
Password Variable PostgreSQL requires: POSTGRES_PASSWORD This is mandatory and injected automatically.
-
Database Initialization Variables PostgreSQL supports: POSTGRES_DB POSTGRES_USER
These are optional but commonly used.
- SSL/TLS Configuration If SSL is enabled, PostgreSQL requires:
CA certificate
Server certificate
Server key
TLS configuration in postgresql.conf
TLS entries in pg_hba.conf
These are generated and mounted automatically.
- Data Directory PostgreSQL stores data in: /var/lib/postgresql/data This directory is mapped to a persistent volume.
StartPostgresql Lifecycle flowchart TD A[StartPostgresql] --> B[Validate Configuration] B --> C[Generate SSL Certificates] C --> D[Generate Persistent Volumes] D --> E[Build Environment Variables] E --> F[Generate Docker Compose] F --> G[Start PostgreSQL Container]
- Validate Configuration StartPostgresql checks:
Port availability
Required password
Volume paths
SSL settings
Custom runtime options
If any required configuration is missing, the action fails early.
- Generate SSL Certificates If SSL is enabled:
A CA certificate is generated
A server certificate is generated
A server key is generated
Certificates are mounted into the container
PostgreSQL is configured to use TLS
Certificates are stored under: /data/coolify/ssl//
- Generate Persistent Volumes Using GeneratesLocalPersistentVolumes, StartPostgresql creates:
Local data directory
SSL directory
Config directory (if needed)
Volumes are mapped into the container: /var/lib/postgresql/data /etc/postgresql/ssl This ensures data persists across container restarts.
- Build Environment Variables StartPostgresql builds a complete environment variable set including:
Required Code POSTGRES_PASSWORD Optional Code POSTGRES_DB POSTGRES_USER System Internal variables required for provisioning.
SSL If TLS is enabled:
Code PGSSLROOTCERT PGSSLCERT PGSSLKEY 5. Generate Docker Compose StartPostgresql generates a full Compose service definition including:
Image Code postgres: Ports Code 5432:5432 Volumes Data directory
SSL directory
Config directory
Environment Variables All normalized variables.
Healthcheck PostgreSQL healthcheck typically uses:
Code pg_isready -U postgres Runtime Options PostgreSQL‑specific flags such as:
Shared memory settings
TLS enforcement
Config overrides
- Start the Container The generated Compose file is passed to the provisioning engine, which:
Creates the container
Applies resource limits
Connects networks
Starts PostgreSQL
Verifies healthcheck
Marks the database as running
Example Compose Snippet (Conceptual example — your implementation generates this dynamically.)
Code services: postgres: image: postgres:16 ports: - "5432:5432" environment: POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}" POSTGRES_DB: "${POSTGRES_DB}" POSTGRES_USER: "${POSTGRES_USER}" volumes: - /data/coolify/postgresql//data:/var/lib/postgresql/data - /data/coolify/ssl/:/etc/postgresql/ssl healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 10s timeout: 5s retries: 5 Why StartPostgresql Is Important StartPostgresql ensures:
Secure defaults
Predictable provisioning
Engine‑specific behavior
SSL/TLS support
Persistent storage
Clean environment variable handling
Consistent Docker orchestration
It is the foundation of PostgreSQL provisioning in your platform.