docker file for postgresql

This commit is contained in:
tom moron
2024-08-11 20:35:58 +02:00
parent eb0539b31e
commit 8ad8d06cae
9 changed files with 66 additions and 4 deletions

View File

@ -23,6 +23,23 @@ services:
ports:
- "9000:9000"
postgresql:
container_name: postgresql
env_file: .env
build:
context: requirements/postgresql
args:
DB_NAME: ${DB_NAME}
DB_USERNAME: ${DB_USERNAME}
DB_PASSWORD: ${DB_PASSWORD}
# volumes:
# - website_data:/var/www/djangoserver
networks:
- transcendence
restart: always
ports:
- "5432:5432"
volumes:
website_data:
driver: local

View File

@ -1,4 +1,4 @@
FROM debian:buster
FROM debian:bullseye
RUN apt update && apt upgrade -y

View File

@ -1,4 +1,4 @@
FROM nginx:latest
FROM nginx:bullseye
RUN mkdir -p /etc/nginx/ssl
RUN apt install -y openssl

View File

@ -0,0 +1,27 @@
FROM debian:bullseye
RUN apt update
RUN apt upgrade -y
RUN apt install postgresql postgresql-client -y
RUN sed -i 's/127.0.0.1\/32/0.0.0.0\/0/' /etc/postgresql/*/*/pg_hba.conf
RUN echo "listen_addresses = '*'" | tee -a /etc/postgresql/*/*/postgresql.conf
COPY setup.sh /root/setup.sh
COPY start.sh /root/start.sh
ARG DB_NAME=;
ARG DB_PASSWORD=;
ARG DB_USERNAME=;
ENV DB_NAME=${DB_NAME}
ENV DB_PASSWORD=${DB_PASSWORD}
ENV DB_USERNAME=${DB_USERNAME}
RUN sh /root/setup.sh
EXPOSE 5432
STOPSIGNAL SIGKILL
ENTRYPOINT ["/bin/sh","/root/start.sh"]

View File

@ -0,0 +1,7 @@
service postgresql start
su postgres << EOF
createdb $DB_NAME
psql -c "CREATE USER $DB_USERNAME WITH PASSWORD '$DB_PASSWORD'"
psql -c "GRANT ALL PRIVILEGES ON database $DB_NAME TO $DB_USERNAME"
EOF

View File

@ -0,0 +1,5 @@
service postgresql start
while :; do
sleep inf
done