* Added initial template for postgresql Container

This commit is contained in:
barry 2025-04-16 14:28:27 -05:00
parent 98989b8a68
commit 7fdefe6741
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,24 @@
FROM almalinux:9-base
# Install PostgreSQL 16 using built-in module
RUN dnf -y update && \
dnf -y module enable postgresql:{{postsgresql_version}} && \
dnf -y install postgresql-server && \
dnf clean all
# Create directory structure without initializing
RUN mkdir -p /var/lib/pgsql/data && \
chown -R postgres:postgres /var/lib/pgsql && \
chmod 700 /var/lib/pgsql/data
# Add entrypoint script
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
USER postgres
ENV PGDATA=/var/lib/pgsql/data
EXPOSE 5432
ENTRYPOINT ["/entrypoint.sh"]
CMD ["postgres", "-D", "/var/lib/pgsql/data"]

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -e
# Initialize only if data directory is empty
if [ -z "$(ls -A $PGDATA)" ]; then
echo "Initializing PostgreSQL database..."
/usr/bin/postgresql-setup --initdb
fi
exec "$@"