* Added initial template for postgresql Container
This commit is contained in:
parent
98989b8a68
commit
7fdefe6741
24
roles/apps/templates/postgres/Containerfile.j2
Normal file
24
roles/apps/templates/postgres/Containerfile.j2
Normal 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"]
|
||||||
|
|
||||||
11
roles/apps/templates/postgres/entrypoint.sh
Normal file
11
roles/apps/templates/postgres/entrypoint.sh
Normal 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 "$@"
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user