docker file for postgresql
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*/.env
|
9
Makefile
9
Makefile
@ -6,7 +6,7 @@
|
||||
# By: tomoron <tomoron@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2024/07/13 16:18:56 by tomoron #+# #+# #
|
||||
# Updated: 2024/08/10 15:24:25 by tomoron ### ########.fr #
|
||||
# Updated: 2024/08/11 16:54:45 by tomoron ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -20,16 +20,21 @@ build:
|
||||
$(COMPOSE) build
|
||||
|
||||
up: build
|
||||
mkdir -p ~/PTME_data
|
||||
$(COMPOSE) up -d
|
||||
up_att: build
|
||||
mkdir -p ~/PTME_data
|
||||
$(COMPOSE) up
|
||||
down:
|
||||
$(COMPOSE) down -v
|
||||
|
||||
fclean:
|
||||
clean:
|
||||
$(COMPOSE) down -v
|
||||
docker system prune -af --volumes
|
||||
|
||||
fclean:clean
|
||||
sudo rm -rf ~/PTME_data
|
||||
|
||||
re: fclean all
|
||||
|
||||
.PHONY: all build up up_att down fclean re
|
||||
|
@ -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
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM debian:buster
|
||||
FROM debian:bullseye
|
||||
|
||||
RUN apt update && apt upgrade -y
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM nginx:latest
|
||||
FROM nginx:bullseye
|
||||
|
||||
RUN mkdir -p /etc/nginx/ssl
|
||||
RUN apt install -y openssl
|
||||
|
27
docker-compose/requirements/postgresql/Dockerfile
Normal file
27
docker-compose/requirements/postgresql/Dockerfile
Normal 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"]
|
7
docker-compose/requirements/postgresql/setup.sh
Normal file
7
docker-compose/requirements/postgresql/setup.sh
Normal 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
|
5
docker-compose/requirements/postgresql/start.sh
Normal file
5
docker-compose/requirements/postgresql/start.sh
Normal file
@ -0,0 +1,5 @@
|
||||
service postgresql start
|
||||
|
||||
while :; do
|
||||
sleep inf
|
||||
done
|
Reference in New Issue
Block a user