initial commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*/.env
|
||||
20
Makefile
Normal file
20
Makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
DETACH ?= true
|
||||
|
||||
all:
|
||||
ifeq ($(DETACH), true)
|
||||
docker-compose -f srcs/docker-compose.yml up -d
|
||||
else
|
||||
docker-compose -f srcs/docker-compose.yml up
|
||||
endif
|
||||
|
||||
clean:
|
||||
docker-compose -f srcs/docker-compose.yml down
|
||||
|
||||
fclean:
|
||||
-docker stop $$(docker ps -qa)
|
||||
-docker rm $$(docker ps -qa)
|
||||
-docker rmi -f $$(docker images -qa)
|
||||
-docker volume rm $$(docker volume ls -q)
|
||||
-docker network rm $$(docker network ls -q) 2>/dev/null
|
||||
re: fclean
|
||||
docker-compose -f srcs/docker-compose.yml up -d
|
||||
66
srcs/docker-compose.yml
Normal file
66
srcs/docker-compose.yml
Normal file
@@ -0,0 +1,66 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
mariadb:
|
||||
container_name: mariadb
|
||||
env_file: .env
|
||||
networks:
|
||||
- inception
|
||||
build:
|
||||
context: requirements/mariadb
|
||||
dockerfile : Dockerfile
|
||||
volumes:
|
||||
- mariadb:/var/lib/mysql
|
||||
restart: unless-stopped
|
||||
expose:
|
||||
- "3306"
|
||||
|
||||
nginx:
|
||||
container_name: nginx
|
||||
env_file: .env
|
||||
volumes:
|
||||
- wordpress:/var/www/wordpress
|
||||
networks:
|
||||
- inception
|
||||
depends_on:
|
||||
- wordpress
|
||||
build:
|
||||
context: requirements/nginx
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "443:443"
|
||||
restart: on-failure
|
||||
|
||||
wordpress:
|
||||
container_name: wordpress
|
||||
env_file: .env
|
||||
volumes:
|
||||
- wordpress:/var/www/wordpress
|
||||
networks:
|
||||
- inception
|
||||
build:
|
||||
context: requirements/wordpress
|
||||
dockerfile: Dockerfile
|
||||
depends_on:
|
||||
- mariadb
|
||||
restart: on-failure
|
||||
expose:
|
||||
- "9000"
|
||||
|
||||
volumes:
|
||||
wordpress:
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: 'none'
|
||||
o: 'bind'
|
||||
device: '/home/vvaas/data/wordpress'
|
||||
mariadb:
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: 'none'
|
||||
o: 'bind'
|
||||
device: '/home/vvaas/data/mariadb'
|
||||
|
||||
networks:
|
||||
inception:
|
||||
driver: bridge
|
||||
18
srcs/requirements/mariadb/Dockerfile
Normal file
18
srcs/requirements/mariadb/Dockerfile
Normal file
@@ -0,0 +1,18 @@
|
||||
FROM debian:buster
|
||||
|
||||
RUN apt update -y
|
||||
RUN apt upgrade -y
|
||||
RUN apt install mariadb-server -y
|
||||
RUN apt install procps -y
|
||||
|
||||
COPY conf/50-server.cnf /etc/mysql/mariadb.conf.d/50-server.cnf
|
||||
#moves the config file from conf to the docker container
|
||||
|
||||
COPY tools/mariadb.sh /mariadb.sh
|
||||
#moves the script inside the docker container
|
||||
|
||||
RUN chmod +x /mariadb.sh
|
||||
|
||||
EXPOSE 3306
|
||||
|
||||
ENTRYPOINT ["/bin/bash", "mariadb.sh"]
|
||||
6
srcs/requirements/mariadb/conf/50-server.cnf
Normal file
6
srcs/requirements/mariadb/conf/50-server.cnf
Normal file
@@ -0,0 +1,6 @@
|
||||
[mysqld]
|
||||
datadir = /var/lib/mysql
|
||||
socket = /run/mysqld/mysqld.sock
|
||||
bind_address = *
|
||||
port = 3306
|
||||
user = mysql
|
||||
15
srcs/requirements/mariadb/tools/mariadb.sh
Normal file
15
srcs/requirements/mariadb/tools/mariadb.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
service mysql start
|
||||
|
||||
echo "CREATE USER IF NOT EXISTS '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_USER';" | mysql
|
||||
echo "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD';" | mysql
|
||||
echo "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD';" | mysql
|
||||
echo "FLUSH PRIVILEGES;" | mysql
|
||||
echo "CREATE DATABASE IF NOT EXISTS $MYSQL_DATABASE;" | mysql
|
||||
|
||||
sleep 2
|
||||
|
||||
service mysql stop
|
||||
|
||||
exec mysqld_safe
|
||||
19
srcs/requirements/nginx/Dockerfile
Normal file
19
srcs/requirements/nginx/Dockerfile
Normal file
@@ -0,0 +1,19 @@
|
||||
FROM debian:buster
|
||||
|
||||
RUN apt update -y
|
||||
RUN apt install nginx -y
|
||||
RUN apt install openssl -y
|
||||
|
||||
RUN mkdir -p /etc/nginx/ssl
|
||||
|
||||
RUN openssl req -x509 -nodes -out /etc/nginx/ssl/inception.crt -keyout /etc/nginx/ssl/inception.key -subj "/C=FR/ST=CM/L=ANgouleme/O=42/OU=42/CN=vvaas/UID=vvaas"
|
||||
#create a non-encrypted SSL certificate
|
||||
COPY conf/nginx.conf /etc/nginx/conf.d
|
||||
# move the nginx config file in conf into the docker container
|
||||
RUN chmod +w /var/www/html
|
||||
RUN chown -R www-data:www-data /var/www/html
|
||||
|
||||
EXPOSE 443
|
||||
|
||||
ENTRYPOINT ["nginx", "-g", "daemon off;"]
|
||||
#start nginx
|
||||
20
srcs/requirements/nginx/conf/nginx.conf
Normal file
20
srcs/requirements/nginx/conf/nginx.conf
Normal file
@@ -0,0 +1,20 @@
|
||||
server {
|
||||
listen 0.0.0.0:443;
|
||||
|
||||
ssl on;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_certificate /etc/nginx/ssl/inception.crt;
|
||||
ssl_certificate_key /etc/nginx/ssl/inception.key;
|
||||
root /var/www/wordpress;
|
||||
server_name vvaas.42.fr;
|
||||
index index.php;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
include snippets/fastcgi-php.conf;
|
||||
fastcgi_pass wordpress:9000;
|
||||
}
|
||||
}
|
||||
34
srcs/requirements/wordpress/Dockerfile
Normal file
34
srcs/requirements/wordpress/Dockerfile
Normal file
@@ -0,0 +1,34 @@
|
||||
FROM debian:buster
|
||||
|
||||
RUN apt update -y
|
||||
RUN apt upgrade -y
|
||||
RUN apt-get install wget -y
|
||||
RUN apt-get install php7.3 -y
|
||||
RUN apt-get install php-fpm -y
|
||||
RUN apt-get install php-mysql -y
|
||||
RUN apt-get install mariadb-client -y
|
||||
RUN apt-get install less -y
|
||||
RUN wget https://fr.wordpress.org/latest-fr_FR.tar.gz -P /var/www
|
||||
#install all dependencies
|
||||
|
||||
RUN cd /var/www && tar -xzf latest-fr_FR.tar.gz && rm latest-fr_FR.tar.gz
|
||||
|
||||
COPY conf/www.conf /etc/php/7.3/fpm/pool.d
|
||||
# copy the config file in conf into the docker container
|
||||
|
||||
RUN wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
|
||||
RUN chmod +x wp-cli.phar
|
||||
RUN mv wp-cli.phar /usr/local/bin/wp.phar
|
||||
#download and install the CLI used in configscript.sh
|
||||
|
||||
RUN chown -R root:root /var/www/wordpress
|
||||
|
||||
COPY conf/configscript.sh configscript.sh
|
||||
#move the script from conf to the docker container
|
||||
|
||||
RUN chmod +x configscript.sh
|
||||
|
||||
EXPOSE 9000
|
||||
|
||||
ENTRYPOINT ["bash", "configscript.sh"]
|
||||
#start the script
|
||||
18
srcs/requirements/wordpress/conf/configscript.sh
Normal file
18
srcs/requirements/wordpress/conf/configscript.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
sleep 10
|
||||
#Waits for mariadb to be fully operational.
|
||||
if [ ! -e /var/www/wordpress/wp-config.php ]; then
|
||||
wp.phar config create --allow-root --dbname=$MYSQL_DATABASE --dbuser=$MYSQL_USER --dbpass=$MYSQL_PASSWORD --dbhost=mariadb:3306 --path='/var/www/wordpress'
|
||||
#Create the wp-config.php.
|
||||
wp.phar core install --allow-root --url=$URL --title=$WP_TITLE --admin_user=$WP_ADMIN_USER --admin_password=$WP_ADMIN_PASSWORD --admin_email=$WP_ADMIN_EMAIL --path='/var/www/wordpress'
|
||||
#install wordpress using the parameters and configs files.
|
||||
wp.phar user create --allow-root --role=author $USER_USER $USER_EMAIL --user_pass=$USER_PASSWORD --path='/var/www/wordpress'
|
||||
#create an user.
|
||||
|
||||
sleep 2
|
||||
fi
|
||||
if [ ! -d /run/php ]; then
|
||||
mkdir /run/php
|
||||
#create the php directory if it's not already created.
|
||||
fi
|
||||
/usr/sbin/php-fpm7.3 -F
|
||||
21
srcs/requirements/wordpress/conf/www.conf
Normal file
21
srcs/requirements/wordpress/conf/www.conf
Normal file
@@ -0,0 +1,21 @@
|
||||
[www]
|
||||
|
||||
user = www-data
|
||||
group = www-data
|
||||
|
||||
listen = wordpress:9000
|
||||
|
||||
listen.owner = www-data
|
||||
listen.group = www-data
|
||||
|
||||
pm = dynamic
|
||||
|
||||
pm.max_children = 5
|
||||
|
||||
pm.start_servers = 2
|
||||
|
||||
pm.min_spare_servers = 1
|
||||
|
||||
pm.max_spare_servers = 3
|
||||
|
||||
clear_env = no
|
||||
Reference in New Issue
Block a user