This commit is contained in:
Danny Houtworm 2023-08-10 04:35:23 +00:00
parent 798be027b7
commit f192cb9509
10 changed files with 63 additions and 52 deletions

View File

@ -2,7 +2,12 @@ all: up
build: build:
sudo docker network create --subnet=172.20.30.0/24 wordpress sudo docker network create --subnet=172.20.30.0/24 wordpress
mkdir ./build sudo mkdir ./build ~/data
sudo curl -f https://wordpress.org/latest.tar.gz --output ~/data/latest.tar.gz
sudo tar -xvf ~/data/latest.tar.gz
sudo mv wordpress ~/data/wordpress
sudo cp srcs/requirements/wordpress/srcs/wordpress.conf ~/data/wordpress/wp-config.php
sudo chown -R root:root ~/data/wordpress
up: build up: build
sudo docker-compose -f ./srcs/docker-compose.yml up -d sudo docker-compose -f ./srcs/docker-compose.yml up -d
@ -12,4 +17,4 @@ down:
clean: down clean: down
yes | sudo docker system prune -a yes | sudo docker system prune -a
sudo rm -rf ./data ./build sudo rm -rf ~/data ./build

View File

@ -4,12 +4,6 @@ Wordpress served by php-fpm with 1 admin and 1 user and redis cache
Mariadb Mariadb
FTP Server pointing to the wordpress volume FTP Server pointing to the wordpress volume
# PID 1
init: true
# /etc/hosts
127.0.0.1 djonker.42.fr
# Volumes # Volumes
all in /home/user/data all in /home/user/data
mariadb database mariadb database

View File

@ -1 +1,3 @@
MARIADBPASSWD=mariapassword WORDPRESSDATABASEPASSWD=password
WORDPRESSDATABASEUSER=wordpress
WORDPRESSDATABASE=wordpress

View File

@ -8,9 +8,7 @@ services:
container_name: nginx container_name: nginx
restart: always restart: always
volumes: volumes:
- ../data/nginx/log/error.log:/var/log/error.log - ~/data/wordpress:/var/www/wordpress
- ../data/nginx/log/access.log:/var/log/access.log
- ../data/wordpress:/var/www/wordpress
ports: ports:
- 80:80 - 80:80
- 443:443 - 443:443
@ -19,13 +17,17 @@ services:
ipv4_address: 172.20.30.10 ipv4_address: 172.20.30.10
mariadb: mariadb:
build: ./requirements/mariadb build: ./requirements/mariadb
environment:
- WORDPRESSDATABASE=${WORDPRESSDATABASE}
- WORDPRESSDATABASEUSER=${WORDPRESSDATABASEUSER}
- WORDPRESSDATABASEPASSWD=${WORDPRESSDATABASEPASSWD}
init: true init: true
container_name: mariadb container_name: mariadb
restart: always restart: always
volumes: volumes:
- ../data/mariadb/data:/var/lib/mysql - ~/data/mariadb/data:/var/lib/mysql
- ../data/mariadb/config:/etc/mysql/conf.d - ~/data/mariadb/config:/etc/mysql/conf.d
- ../data/mariadb/logs:/var/log/mysql - ~/data/mariadb/logs:/var/log/mysql
networks: networks:
wordpress: wordpress:
ipv4_address: 172.20.30.20 ipv4_address: 172.20.30.20
@ -34,7 +36,7 @@ services:
container_name: wordpress container_name: wordpress
restart: always restart: always
volumes: volumes:
- ../data/wordpress:/var/www/wordpress - ~/data/wordpress:/var/www/wordpress
networks: networks:
wordpress: wordpress:
ipv4_address: 172.20.30.30 ipv4_address: 172.20.30.30

View File

@ -1,4 +1,7 @@
FROM alpine FROM alpine
ARG WORDPRESSDATABASE=${WORDPRESSDATABASE}
ARG WORDPRESSDATABASEUSER=${WORDPRESSDATABASEUSER}
ARG WORDPRESSDATABASEPASSWD=${WORDPRESSDATABASEPASSWD}
RUN sleep 10 RUN sleep 10
RUN apk update RUN apk update
RUN apk add mariadb RUN apk add mariadb

View File

@ -5,7 +5,9 @@ then
else else
mysql_install_db --user=mysql --datadir=/var/lib/mysql mysql_install_db --user=mysql --datadir=/var/lib/mysql
mysqld & sleep 10 mysqld & sleep 10
mysql < maria.sql #mysql < maria.sql
mysql -e "CREATE DATABASE $WORDPRESSDATABASE"
mysql -e "GRANT ALL PRIVILEGES ON $WORDPRESSDATABASE.* TO $WORDPRESSDATABASEUSER@172.20.30.30 IDENTIFIED BY '$WORDPRESSDATABASEPASSWD'"
killall mysqld killall mysqld
touch /var/lib/mysql/initialized touch /var/lib/mysql/initialized
fi fi

View File

@ -20,6 +20,35 @@ http {
gzip_vary on; gzip_vary on;
gzip_types text/plain text/css application/json application/x-javascript application/javascript text/xml application/xml application/rss+xml text/javascript image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype; gzip_types text/plain text/css application/json application/x-javascript application/javascript text/xml application/xml application/rss+xml text/javascript image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype;
server {
listen 443 ssl;
ssl_certificate /etc/ssl/certs/nginx.crt;
ssl_certificate_key /etc/ssl/private/nginx.key;
server_name djonker.42.fr localhost;
root /var/www/wordpress;
index index.php;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_session_timeout 10m;
keepalive_timeout 70;
location / {
try_files $uri /index.php?$args;
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache';
if_modified_since off;
expires off;
etag off;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 172.20.30.30:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
server { server {
listen 443 ssl; listen 443 ssl;
@ -27,7 +56,7 @@ http {
ssl_certificate_key /etc/ssl/private/nginx.key; ssl_certificate_key /etc/ssl/private/nginx.key;
root /var/www/html; root /var/www/html;
index index.php index.html index.htm; index index.php index.html index.htm;
server_name djonker.42.fr localhost; server_name html.djonker.42.fr localhost;
location / { location / {
autoindex on; autoindex on;
@ -35,22 +64,6 @@ http {
} }
} }
server {
listen 443 ssl;
ssl_certificate /etc/ssl/certs/nginx.crt;
ssl_certificate_key /etc/ssl/private/nginx.key;
root /var/www/wordpress;
index index.php index.html index.htm;
server_name djonker.42.fr localhost;
location = /wordpress {
fastcgi_pass 172.20.30.30:9000;
fastcgi_index index.php;
fastcgi_param HTTP_PROXY "";
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
server { server {
listen 80; listen 80;

View File

@ -11,19 +11,8 @@ RUN apk add php-curl
RUN apk add php-json RUN apk add php-json
RUN apk add php-xml RUN apk add php-xml
RUN apk add php-zip RUN apk add php-zip
COPY srcs/start.sh /root/start.sh
COPY srcs/www.conf /etc/php81/php-fpm.d/www.conf COPY srcs/www.conf /etc/php81/php-fpm.d/www.conf
COPY srcs/wordpress.conf /var/www/wordpress/wp-config.php COPY srcs/wordpress.conf /var/www/wordpress/wp-config.php
WORKDIR /root/ WORKDIR /root/
RUN wget https://wordpress.org/latest.tar.gz
RUN tar -xvf latest.tar.gz
RUN mv wordpress/* /var/www/wordpress/
RUN chown -R root:root /var/www
RUN openssl genrsa -out nginx.key
RUN openssl req -new -key nginx.key -out nginx.csr -subj "/C=NL/ST=Friesland/L=Heerenveen/O=localhost/OU=localhost/CN=localhost/emailAddress=djonker@student.codam.nl"
RUN openssl x509 -req -days 365 -in nginx.csr -signkey nginx.key -out nginx.crt
RUN mv nginx.crt /etc/ssl/certs/nginx.crt
RUN mv nginx.key /etc/ssl/private/nginx.key
RUN chmod 600 /etc/ssl/certs/nginx.crt /etc/ssl/private/nginx.key
CMD php-fpm81 -F -R CMD php-fpm81 -F -R
EXPOSE 9000/tcp EXPOSE 9000/tcp

View File

@ -29,7 +29,7 @@ define( 'DB_USER', 'wordpress' );
define( 'DB_PASSWORD', 'password' ); define( 'DB_PASSWORD', 'password' );
/** MySQL hostname */ /** MySQL hostname */
define( 'DB_HOST', 'mariadb' ); define( 'DB_HOST', '172.20.30.20' );
/** Database Charset to use in creating database tables. */ /** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8mb4' ); define( 'DB_CHARSET', 'utf8mb4' );
@ -37,8 +37,8 @@ define( 'DB_CHARSET', 'utf8mb4' );
/** The Database Collate type. Don't change this if in doubt. */ /** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' ); define( 'DB_COLLATE', '' );
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/'); define('WP_SITEURL', 'https://djonker.42.fr');
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/'); define('WP_HOME', 'https://djonker.42.fr');
/**#@+ /**#@+
* Authentication Unique Keys and Salts. * Authentication Unique Keys and Salts.
@ -81,7 +81,6 @@ $table_prefix = 'wp_';
* @link https://wordpress.org/support/article/debugging-in-wordpress/ * @link https://wordpress.org/support/article/debugging-in-wordpress/
*/ */
define( 'WP_DEBUG', false ); define( 'WP_DEBUG', false );
/* That's all, stop editing! Happy publishing. */ /* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */ /** Absolute path to the WordPress directory. */

View File

@ -38,7 +38,9 @@ group = nobody
; (IPv6 and IPv4-mapped) on a specific port; ; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket. ; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory. ; Note: This value is mandatory.
listen = 172.20.30.10:9000 ;listen = 172.20.30.10:9000
;listen = 127.0.0.1:9000
listen = 9000
; Set listen(2) backlog. ; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD) ; Default Value: 511 (-1 on FreeBSD and OpenBSD)
@ -66,7 +68,7 @@ listen = 172.20.30.10:9000
; must be separated by a comma. If this value is left blank, connections will be ; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address. ; accepted from any ip address.
; Default Value: any ; Default Value: any
;listen.allowed_clients = 127.0.0.1 listen.allowed_clients = 172.20.30.10
; Specify the nice(2) priority to apply to the pool processes (only if set) ; Specify the nice(2) priority to apply to the pool processes (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority) ; The value can vary from -19 (highest priority) to 20 (lower priority)
@ -432,7 +434,7 @@ pm.max_spare_servers = 3
; execute php code. ; execute php code.
; Note: set an empty value to allow all extensions. ; Note: set an empty value to allow all extensions.
; Default Value: .php ; Default Value: .php
;security.limit_extensions = .php .php3 .php4 .php5 .php7 security.limit_extensions =
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment. ; the current environment.