Dockerfile (1257B)
1 # ============================================================ 2 # PostgreSQL Database Container 3 # ============================================================ 4 # Multi-schema database for ecommerce microservices 5 # Schemas: products, inventory, orders 6 7 FROM postgres:17-alpine 8 9 # Set environment variables for PostgreSQL 10 ENV POSTGRES_DB=ecommerce \ 11 POSTGRES_USER=ecommerce_user \ 12 POSTGRES_PASSWORD=ecommerce_password \ 13 POSTGRES_INITDB_ARGS="--encoding=UTF8 --locale=en_US.UTF-8" 14 15 # Set PostgreSQL configuration 16 ENV POSTGRES_HOST_AUTH_METHOD=scram-sha-256 17 18 # Copy initialization scripts 19 # These will be executed in alphabetical order when container starts 20 COPY init/*.sql /docker-entrypoint-initdb.d/ 21 22 # Expose PostgreSQL port 23 EXPOSE 5432 24 25 # Add labels 26 LABEL maintainer="OpenTel Book Team" \ 27 description="PostgreSQL database with multi-schema setup for ecommerce microservices" \ 28 version="1.0" \ 29 schemas="products,inventory,orders,users" 30 31 # Health check 32 HEALTHCHECK --interval=10s --timeout=5s --start-period=30s --retries=3 \ 33 CMD pg_isready -U $POSTGRES_USER -d $POSTGRES_DB || exit 1 34 35 # Volume for persistent data 36 VOLUME ["/var/lib/postgresql/data"] 37 38 # The default CMD from postgres:17-alpine will be used 39 # CMD ["postgres"]