Compare commits

...

4 Commits

Author SHA1 Message Date
193c18c47a upgrade makefile, add env var to mariadb 2023-10-07 17:01:56 +02:00
0b52e973e3 add: network and volumes 2023-10-07 16:52:15 +02:00
78b202c264 fix 2023-10-05 12:15:34 -04:00
1d5eb6c1b6 add: container name, depend_on, env_file, maria db 2023-10-05 12:15:15 -04:00
6 changed files with 59 additions and 5 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

@ -1,17 +1,62 @@
version: "3"
services: services:
nginx: nginx:
container_name: nginx
image: nginx image: nginx
build: nginx build: nginx
ports: ports:
- "443:443" - "443:443"
volumes: volumes:
- wordpress:/var/www/wordpress - wordpress:/var/www/wordpress
depends_on:
- wordpress
networks:
- inception
restart: always
wordpress: wordpress:
container_name: wordpress
image: wordpress image: wordpress
build: wordpress build: wordpress
volumes: volumes:
- wordpress:/var/www/wordpress - wordpress:/var/www/wordpress
depends_on:
- mariadb
env_file:
- .env
networks:
- inception
restart: always
mariadb:
container_name: mariadb
image: mariadb
build: mariadb
volumes:
- mariadb:/data
env_file:
- .env
networks:
- inception
restart: always
volumes: volumes:
wordpress: wordpress:
driver: local
driver_opts:
type: 'none'
o: 'bind'
device: '/home/cchauvet/data/wp-files/'
mariadb:
driver: local
driver_opts:
type: 'none'
o: 'bind'
device: '/home/cchauvet/data/wp-db/'
networks:
inception:
driver: bridge

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';

View File

@ -10,7 +10,7 @@ server {
index index.php; index index.php;
location / { location / {
try_files $uri $uri/ =404; try_files $uri $uri/ /index.php?$args;
} }
location ~ \.php$ { location ~ \.php$ {
include fastcgi_params; include fastcgi_params;