From 409599d558ac66c758e7e892cd15d6ceb92a874d Mon Sep 17 00:00:00 2001 From: hugo gogo Date: Tue, 6 Sep 2022 12:45:50 +0200 Subject: [PATCH] try to build nginx from alpine --- srcs/docker-compose.yml | 16 ++++++---- srcs/requirements/mariadb/Dockerfile | 6 +++- srcs/requirements/nginx/Dockerfile | 18 +++++++++-- .../nginx/conf/inception_nginx.conf | 32 +++++++++---------- 4 files changed, 45 insertions(+), 27 deletions(-) diff --git a/srcs/docker-compose.yml b/srcs/docker-compose.yml index 35a724e..33d4c7e 100644 --- a/srcs/docker-compose.yml +++ b/srcs/docker-compose.yml @@ -29,16 +29,18 @@ services: context: ./requirements/nginx dockerfile: Dockerfile image: nginx + # image: nginx_debian container_name: mynginx + # container_name: mynginx_debian # --------------------------------- - mariadb: -# restart: on-failure - build: - context: ./requirements/mariadb - dockerfile: Dockerfile - image: mariadb - container_name: mymariadb +# mariadb: +## restart: on-failure +# build: +# context: ./requirements/mariadb +# dockerfile: Dockerfile +# image: mariadb +# container_name: mymariadb # --------------------------------- diff --git a/srcs/requirements/mariadb/Dockerfile b/srcs/requirements/mariadb/Dockerfile index 1c0b068..8470698 100644 --- a/srcs/requirements/mariadb/Dockerfile +++ b/srcs/requirements/mariadb/Dockerfile @@ -2,6 +2,10 @@ FROM debian:buster RUN apt update && apt install -y mariadb-client mariadb-server -RUN mariadb --execute="create database db_hugo_test; create user 'u_hugo_test'@'localhost' identified by 'hello'; grant all privileges on *.* to 'u_hugo_test'@'localhost' with grant option;" +RUN service mysql start +RUN mariadb --execute="create database db_hugo_test;" +RUN mariadb --execute="create user 'u_hugo_test'@'localhost' identified by 'hello';" +RUN mariadb --execute="grant all privileges on *.* to 'u_hugo_test'@'localhost' with grant option;" CMD [ "mysqld" ] + diff --git a/srcs/requirements/nginx/Dockerfile b/srcs/requirements/nginx/Dockerfile index a0ce1b7..851c0ca 100644 --- a/srcs/requirements/nginx/Dockerfile +++ b/srcs/requirements/nginx/Dockerfile @@ -1,11 +1,20 @@ -#FROM alpine:3.15 -FROM debian:buster +# alpine : +FROM alpine:3.15 +# debian : +#FROM debian:buster -RUN apt update && apt install -y nginx openssl +# alpine : +RUN apk add nginx openssl +# debian : +#RUN apt update && apt install -y nginx openssl && rm -rf /var/lib/apt/lists/* # for debug #RUN apt install -y procps vim +# alpine : +RUN mkdir -p /etc/ssl/private +RUN mkdir -p /etc/ssl/certs + # create ssl certificate RUN openssl req -newkey rsa:2048 -nodes -x509 \ -keyout /etc/ssl/private/hulamy.42.fr.key -out /etc/ssl/certs/hulamy.42.fr.crt \ @@ -22,6 +31,9 @@ COPY ./conf/https/index.html /data/wwws/ CMD [ "nginx", "-g", "daemon off;" ] +# +# run nginx with alpine : +# https://www.techtarget.com/searchitoperations/tutorial/Use-Docker-and-Alpine-Linux-to-build-lightweight-containers # # -g 'daemon off' : # daemon off, to avoid the main process of nginx to quit after creating its childs, and therefore make docker exit diff --git a/srcs/requirements/nginx/conf/inception_nginx.conf b/srcs/requirements/nginx/conf/inception_nginx.conf index 20a7301..0f2ef62 100644 --- a/srcs/requirements/nginx/conf/inception_nginx.conf +++ b/srcs/requirements/nginx/conf/inception_nginx.conf @@ -11,19 +11,19 @@ server { # return 301 https://$host$request_uri; # redirect on https } -server { - listen 443 ssl; # for ipv4, on port 443, specifying that accepted connections should works in ssl mode - listen [::]:443 ssl; # for ipv6 - server_name hulamy.42.fr; - ssl_certificate /etc/ssl/certs/hulamy.42.fr.crt; # specifies the file with the ssl certificate (self signed here) generated by openssl - ssl_certificate_key /etc/ssl/private/hulamy.42.fr.key; # specifies the file with the secret key of the certificate - - root /var/www/html/; # contains default nginx index.nginx-debian.html - index index.html index.htm index.nginx-debian.html index.php; # defines files that will be used as index (https://nginx.org/en/docs/http/ngx_http_index_module.html) - - location / { - try_files $uri $uri/ =404; # from /etc/nginx/sites-enabled/default : First attempt to serve request as file, then as directory, then fall back to displaying a 404 - # for test - root /data/wwws/; - } -} +#server { +# listen 443 ssl; # for ipv4, on port 443, specifying that accepted connections should works in ssl mode +# listen [::]:443 ssl; # for ipv6 +# server_name hulamy.42.fr; +# ssl_certificate /etc/ssl/certs/hulamy.42.fr.crt; # specifies the file with the ssl certificate (self signed here) generated by openssl +# ssl_certificate_key /etc/ssl/private/hulamy.42.fr.key; # specifies the file with the secret key of the certificate +# +# root /var/www/html/; # contains default nginx index.nginx-debian.html +# index index.html index.htm index.nginx-debian.html index.php; # defines files that will be used as index (https://nginx.org/en/docs/http/ngx_http_index_module.html) +# +# location / { +# try_files $uri $uri/ =404; # from /etc/nginx/sites-enabled/default : First attempt to serve request as file, then as directory, then fall back to displaying a 404 +# # for test +# root /data/wwws/; +# } +#}