diff --git a/srcs/docker-compose.yml b/srcs/docker-compose.yml index f10299f..36b802f 100644 --- a/srcs/docker-compose.yml +++ b/srcs/docker-compose.yml @@ -3,11 +3,15 @@ name: inception volumes: wp-db: wp-site: + nginx-certs: networks: inception: external: false +include: + - docker/bonus/compose.yml + services: nginx: container_name: inception-nginx @@ -30,6 +34,7 @@ services: - wp-site:/var/www/wordpress - ./configs/nginx/templates:/etc/nginx/templates - ./configs/nginx/entry:/docker-entrypoint.d + - nginx-certs:/etc/nginx/ssl ports: - "8443:8443" restart: unless-stopped diff --git a/srcs/docker/bonus/compose.yml b/srcs/docker/bonus/compose.yml new file mode 100644 index 0000000..103b1ef --- /dev/null +++ b/srcs/docker/bonus/compose.yml @@ -0,0 +1,11 @@ +services: + static-site: + build: static-site + ports: + - 8080:443 + depends_on: + - nginx + environment: + - TZ=Europe/Paris + - NGINX_SSL_KEY_FILE=/etc/nginx/ssl/kanel-wp.key + - NGINX_SSL_CERT_FILE=/etc/nginx/ssl/kanel-wp.crt diff --git a/srcs/docker/bonus/static-site/Dockerfile b/srcs/docker/bonus/static-site/Dockerfile new file mode 100644 index 0000000..b3f5fe1 --- /dev/null +++ b/srcs/docker/bonus/static-site/Dockerfile @@ -0,0 +1,8 @@ +FROM inception-nginx + +LABEL maintainer="KeyZox" + + +COPY kanelovh/ /var/www/html/ +COPY --chmod=644 www.conf.template /etc/nginx/templates/www.conf.template +COPY --chmod=644 cert.sh /docker-entrypoint.d/ diff --git a/srcs/docker/bonus/static-site/cert.sh b/srcs/docker/bonus/static-site/cert.sh new file mode 100644 index 0000000..5e1a62f --- /dev/null +++ b/srcs/docker/bonus/static-site/cert.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ ! -f ${NGINX_SSL_KEY_FILE} ]; then + echo "Generating certs" + mkdir -p /etc/nginx/ssl + openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ${NGINX_SSL_KEY_FILE} -out ${NGINX_SSL_CERT_FILE} -subj "/C=FR/ST=IDF/L=Angouleme/O=42/OU=42/CN=kanel.ovh/UID=adjoly" +else + printf "Key already exist not recreating\n" +fi diff --git a/srcs/docker/bonus/static-site/kanelovh/index.html b/srcs/docker/bonus/static-site/kanelovh/index.html new file mode 100644 index 0000000..3894c5a --- /dev/null +++ b/srcs/docker/bonus/static-site/kanelovh/index.html @@ -0,0 +1,15 @@ + + + + + + Kanel Supremacy + + + +
+ +
+ + + \ No newline at end of file diff --git a/srcs/docker/bonus/static-site/kanelovh/script.js b/srcs/docker/bonus/static-site/kanelovh/script.js new file mode 100644 index 0000000..4312378 --- /dev/null +++ b/srcs/docker/bonus/static-site/kanelovh/script.js @@ -0,0 +1,24 @@ +function init() +{ + var img = document.querySelector("#kanel"); + const random = Math.floor(Math.random() * 70) + 1; + img.src = 'https://kanel.ovh/img/'+random+'.jpg'; + const { naturalWidth, naturalHeight } = img; + const isLandscape = naturalWidth / naturalHeight > 1; + + if (isLandscape) { + img.style.width = window.innerWidth+'px'; + img.style.height = 'auto'; + } else { + img.style.height = window.innerHeight+'px'; + img.style.width = 'auto'; + } + + if (img.src == 'https://kanel.ovh/img/70.jpg') + { + img.style.height = 'auto'; + img.style.width = '100%'; + } +} + +init(); diff --git a/srcs/docker/bonus/static-site/kanelovh/style.css b/srcs/docker/bonus/static-site/kanelovh/style.css new file mode 100644 index 0000000..80278a0 --- /dev/null +++ b/srcs/docker/bonus/static-site/kanelovh/style.css @@ -0,0 +1,28 @@ +body, html +{ + margin: 0; + padding: 0; + display: flex; + align-items: center; + justify-content: center; + background-color: #f0f0f0; + overflow: hidden; + box-sizing: border-box; +} + +.image-container +{ + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; + overflow: hidden; + position: relative; +} + +.img +{ + width: 100%; + height: auto; +} \ No newline at end of file diff --git a/srcs/docker/bonus/static-site/www.conf.template b/srcs/docker/bonus/static-site/www.conf.template new file mode 100644 index 0000000..9fe960d --- /dev/null +++ b/srcs/docker/bonus/static-site/www.conf.template @@ -0,0 +1,17 @@ +server { + listen 0.0.0.0:443 ssl; + + root /var/www/html; + index index.html; + + ssl_certificate $NGINX_SSL_CERT_FILE; + ssl_certificate_key $NGINX_SSL_KEY_FILE; + ssl_protocols TLSv1.2 TLSv1.3; + ssl_session_timeout 10m; + + keepalive_timeout 60; + + location / { + try_files $${q}uri $${q}uri/ =404; + } +} diff --git a/srcs/docker/mariadb/Dockerfile b/srcs/docker/mariadb/Dockerfile index 2e093c6..7e5d081 100644 --- a/srcs/docker/mariadb/Dockerfile +++ b/srcs/docker/mariadb/Dockerfile @@ -39,4 +39,4 @@ WORKDIR /var/lib/mysql EXPOSE 3306 CMD [ "mariadbd", "--user=mysql" ] -HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=1s --start-interval=2s CMD /docker-healthcheck +HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=3s --start-interval=2s CMD /docker-healthcheck diff --git a/srcs/docker/nginx/Dockerfile b/srcs/docker/nginx/Dockerfile index 7562023..e1f8378 100644 --- a/srcs/docker/nginx/Dockerfile +++ b/srcs/docker/nginx/Dockerfile @@ -37,4 +37,4 @@ STOPSIGNAL SIGQUIT EXPOSE 80 CMD [ "nginx", "-g", "daemon off;" ] -HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=1s --start-interval=2s CMD curl http://127.0.0.1:80/health || exit 1 +HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=3s --start-interval=2s CMD curl http://127.0.0.1:80/health || exit 1 diff --git a/srcs/docker/wordpress/Dockerfile b/srcs/docker/wordpress/Dockerfile index c09487f..afe7426 100644 --- a/srcs/docker/wordpress/Dockerfile +++ b/srcs/docker/wordpress/Dockerfile @@ -58,4 +58,4 @@ STOPSIGNAL SIGQUIT EXPOSE 9000 CMD [ "php-fpm84", "-F" ] -HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=1s --start-interval=2s CMD cgi-fcgi -bind -connect 127.0.0.1:${PHP_PORT:-9000} || exit 1 +HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=3s --start-interval=2s CMD cgi-fcgi -bind -connect 127.0.0.1:${PHP_PORT:-9000} || exit 1