upgrade makefile, add env var to mariadb

This commit is contained in:
starnakin 2023-10-07 17:01:56 +02:00
parent 0b52e973e3
commit 193c18c47a
5 changed files with 16 additions and 4 deletions

View File

@ -1,13 +1,16 @@
all: up all: up
run: run:
@mkdir -p /home/cchauvet/data/wp-files
@mkdir -p /home/cchauvet/data/wp-db
docker-compose -f srcs/docker-compose.yml up --build -d docker-compose -f srcs/docker-compose.yml up --build -d
fclean: fclean:
-docker rm -f `docker ps -aq` -docker rm -f `docker ps -aq`
-docker volume rm -f `docker volume ls -q` -docker volume rm -f `docker volume ls -q`
-docker image rm -f `docker image ls -aq` -docker image rm -f `docker image ls -aq`
-docker network rm -f `docker network ls -q` -docker network rm `docker network ls -q`
-docker builder prune --all --force -docker builder prune --all --force
rm -rf /home/cchauvet/data/wp-files /home/cchauvet/data/wp-db
up: run up: run

View File

@ -12,6 +12,7 @@ services:
- wordpress - wordpress
networks: networks:
- inception - inception
restart: always
wordpress: wordpress:
container_name: wordpress container_name: wordpress
@ -25,6 +26,7 @@ services:
- .env - .env
networks: networks:
- inception - inception
restart: always
mariadb: mariadb:
container_name: mariadb container_name: mariadb
@ -36,6 +38,7 @@ services:
- .env - .env
networks: networks:
- inception - inception
restart: always
volumes: volumes:

View File

@ -5,6 +5,6 @@ RUN apk update
RUN apk add mariadb RUN apk add mariadb
RUN mariadb-install-db RUN mariadb-install-db
RUN mkdir /run/mysqld RUN mkdir /run/mysqld
COPY init.sql /etc COPY init.sql entrypoint.sh /etc/
ENTRYPOINT ["mariadbd", "--no-defaults", "--user=root", "--datadir=/data", "--init-file=/etc/init.sql"] ENTRYPOINT ["sh", "/etc/entrypoint.sh"]

View File

@ -0,0 +1,6 @@
sed -i "s/DB_USER/$DB_USER/g" /etc/init.sql
sed -i "s/DB_PASS/$DB_PASS/g" /etc/init.sql
cat /etc/init.sql >/dev/stderr
exec mariadbd --no-defaults --user=root --datadir=/data --init-file=/etc/init.sql

View File

@ -1,2 +1,2 @@
CREATE DATABASE wordpress; CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'%' IDENTIFIED BY 'wordpress'; GRANT ALL PRIVILEGES ON wordpress.* TO 'DB_USER'@'%' IDENTIFIED BY 'DB_PASS';