1
0

🏗️」 wip: should be working but not

This commit is contained in:
2025-02-07 18:55:44 +01:00
parent 610eac560e
commit f0659b8206
13 changed files with 147 additions and 35 deletions

View File

@ -8,19 +8,11 @@ DOCKERFILE_DB := $(DOCKER_CONTEXT)$(DOCKER_FOLDER)/$(DB_SERVER_NAME)/Dockerfile
DOCKERFILE_WEVSRV := $(DOCKER_CONTEXT)$(DOCKER_FOLDER)/$(WEB_SERVER_NAME)/Dockerfile DOCKERFILE_WEVSRV := $(DOCKER_CONTEXT)$(DOCKER_FOLDER)/$(WEB_SERVER_NAME)/Dockerfile
DOCKERFILE_CMS := $(DOCKER_CONTEXT)$(DOCKER_FOLDER)/$(CMS_NAME)/Dockerfile DOCKERFILE_CMS := $(DOCKER_CONTEXT)$(DOCKER_FOLDER)/$(CMS_NAME)/Dockerfile
dev: include srcs/docker/composes/dev/dev.mk
docker compose --profile dev -f $(DOCKER_CONTEXT)docker-compose.yml up -d --build include srcs/docker/composes/correction.mk
include srcs/docker/composes/prod.mk
prod: all: setup-corr correction
docker compose -f $(DOCKER_CONTEXT)docker-compose.yml up -d --build
all: dev
stop:
docker compose --profile dev -f $(DOCKER_CONTEXT)docker-compose.yml stop
stop-prod:
docker compose -f $(DOCKER_CONTEXT)docker-compose-prod.yml stop
clean: stop clean: stop
docker system prune docker system prune
@ -30,4 +22,4 @@ fclean: clean
re: clean all re: clean all
.PHONY: cms-build db-build websrv-build clean-db clean-nginx .PHONY: all clean fclean re

View File

@ -1,22 +1,8 @@
#!/bin/sh #!/bin/sh
if [ ! -v ${PRODUCTION} ]; then if [ ! -f ${NGINX_SSL_KEY_FILE} ]; then
if [ ! -f ${NGINX_SSL_KEY_FILE} ]; then echo "Generating certs"
echo "Generating certs" mkdir -p /etc/nginx/ssl
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=adjoly.42.fr/UID=adjoly"
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=adjoly.42.fr/UID=adjoly"
else
printf "Key already exist not recreating\n"
fi
else else
printf "Entering production mode for nginx" printf "Key already exist not recreating\n"
INPUT_FILE="/etc/nginx/http.d/www.conf"
OUTPUT_FILE="/etc/nginx/http.d/www.conf"
sed -E '
s/listen\s+443 ssl;/listen 80;/;
s/server_name.*/&\n\tlisten 80;/;
/ssl_certificate/d;
/ssl_certificate_key/d;
/ssl_protocols/d;
/ssl_session_timeout/d;
' "$INPUT_FILE" > "$OUTPUT_FILE"
fi fi

View File

@ -0,0 +1,24 @@
server {
listen localhost:443 ssl;
root /var/www/html;
index index.php;
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;
}
location ~ \.php$ {
fastcgi_pass $NGINX_PHP_HOST:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi.conf;
}
}

View File

@ -7,6 +7,12 @@ include:
project_directory: ./ project_directory: ./
- path: ./docker/composes/db.yml - path: ./docker/composes/db.yml
project_directory: ./ project_directory: ./
- path: ./docker/composes/dev/nginx.yml
project_directory: ./
- path: ./docker/composes/dev/wordp-php.yml
project_directory: ./
- path: ./docker/composes/dev/db.yml
project_directory: ./
networks: networks:
inception: inception:

View File

@ -0,0 +1,10 @@
setup-corr:
mkdir -P $HOME/data
correction:
docker compose --profile correction -f $(DOCKER_CONTEXT)docker-compose.yml up -d --build
stop:
docker compose --profile correction -f $(DOCKER_CONTEXT)docker-compose.yml stop
.PHONY: stop correction setup-corr

View File

@ -18,3 +18,5 @@ services:
volumes: volumes:
- wp-db:/var/lib/mysql - wp-db:/var/lib/mysql
restart: unless-stopped restart: unless-stopped
profiles:
- correction

View File

@ -0,0 +1,19 @@
services:
db-dev:
container_name: inception-db
build:
context: .
dockerfile: docker/images/mariadb/Dockerfile
networks:
- inception
environment:
- MYSQL_ROOT_PASSWORD="alpine"
- MYSQL_PASSWORD="alpine"
- MYSQL_USER="kanel"
- MYSQL_DATABASE="knl"
- TZ=Europe/Paris
volumes:
- wp-db:/var/lib/mysql
restart: unless-stopped
profiles:
- dev

View File

@ -0,0 +1,9 @@
# those rules a for developement purposes
dev:
docker compose --profile dev -f $(DOCKER_CONTEXT)docker-compose.yml up -d --build
stop-dev:
docker compose --profile dev -f $(DOCKER_CONTEXT)docker-compose.yml stop
.PHONY: dev stop-dev

View File

@ -0,0 +1,27 @@
services:
nginx-dev:
container_name: inception-nginx
build:
context: .
dockerfile: docker/images/nginx/Dockerfile
networks:
- inception
environment:
- TZ=Europe/Paris
- NGINX_PHP_HOST=inception-wordp-php
- NGINX_SSL_KEY_FILE=/etc/nginx/ssl/adjoly-wp.key
- NGINX_SSL_CERT_FILE=/etc/nginx/ssl/adjoly-wp.crt
depends_on:
wordpress-php-dev:
condition: service_healthy
db-dev:
condition: service_healthy
volumes:
- wp-site:/var/www/html
- ./configs/nginx/templates-dev:/etc/nginx/templates
- ./configs/nginx/entry:/docker-entrypoint.d
ports:
- "443:443"
restart: unless-stopped
profiles:
- dev

View File

@ -0,0 +1,24 @@
volumes:
wp-site:
services:
wordpress-php-dev:
container_name: inception-wordp-php
build:
context: .
dockerfile: docker/images/wordpress/Dockerfile
networks:
- inception
depends_on:
db-dev:
condition: service_healthy
environment:
- PHP_MEMORY_LIMIT="512M"
- PHP_MAX_UPLOAD="50M"
- PHP_PORT=9000
- TZ=Europe/Paris
volumes:
- wp-site:/var/www/html
restart: unless-stopped
profiles:
- dev

View File

@ -3,14 +3,14 @@ volumes:
name: nginx-templates name: nginx-templates
driver: local driver: local
driver_opts: driver_opts:
device: ./configs/nginx/templates device: $HOME/data/nginx/templates
o: "bind,ro" o: "bind,ro"
type: none type: none
nginx-entry: nginx-entry:
name: nginx-entry name: nginx-entry
driver: local driver: local
driver_opts: driver_opts:
device: ./configs/nginx/entry device: $HOME/data/nginx/entry
o: "bind,ro" o: "bind,ro"
type: none type: none
@ -41,3 +41,5 @@ services:
ports: ports:
- "10443:443" - "10443:443"
restart: unless-stopped restart: unless-stopped
profiles:
- correction

View File

@ -0,0 +1,9 @@
# those are for production testing only do not execute in production environment
prod:
docker compose -f $(DOCKER_CONTEXT)docker-compose.yml up -d --build
stop-prod:
docker compose -f $(DOCKER_CONTEXT)docker-compose-prod.yml stop
.PHONY: prod stop-prod

View File

@ -20,3 +20,5 @@ services:
volumes: volumes:
- wp-site:/var/www/html - wp-site:/var/www/html
restart: unless-stopped restart: unless-stopped
profiles:
- correction