# Copyright 2026 Umbra Tools (umbratools.com)
# SPDX-License-Identifier: Apache-2.0

# UmbraDatastore - PostgreSQL with UmbraTrans schema
# Based on CloudNativePG PostgreSQL 16.4
# Note: CloudNativePG base image already includes pgcrypto, uuid-ossp, citext extensions

FROM ghcr.io/cloudnative-pg/postgresql:16.4

# Copy migration scripts to be run on initialization
# These will be executed by CNPG's postInitApplicationSQL or via initdb
COPY migrations/ /docker-entrypoint-initdb.d/

# Labels
LABEL org.opencontainers.image.title="UmbraDatastore" \
      org.opencontainers.image.description="PostgreSQL with UmbraTrans schema for UmbraTrans" \
      org.opencontainers.image.version="16.4" \
      org.opencontainers.image.source="http://192.168.123.18:3001/umbragit/UmbraDatastore" \
      org.opencontainers.image.licenses="Apache-2.0"

# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
    CMD pg_isready -U umbratrans -d umbratrans || exit 1

# Default command (handled by CNPG)
CMD ["postgres"]
