From 96290b796b806ad8502071ba4a00fb4f5b0a6c4d Mon Sep 17 00:00:00 2001 From: hugo gogo Date: Tue, 6 Sep 2022 17:37:52 +0200 Subject: [PATCH] mariadb running ok --- Makefile | 3 ++- srcs/docker-compose.yml | 14 +++++++------- srcs/requirements/mariadb/Dockerfile | 14 +++++++++----- srcs/requirements/nginx/Dockerfile | 17 ++--------------- 4 files changed, 20 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index e41309a..4f4771c 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,8 @@ RESET = "\e[0m" COMPOSE = ./srcs/docker-compose.yml IMAGES = test \ - nginx + nginx \ + mariadb HOME_D = $(shell echo $(HOME)) diff --git a/srcs/docker-compose.yml b/srcs/docker-compose.yml index 33d4c7e..a29ab64 100644 --- a/srcs/docker-compose.yml +++ b/srcs/docker-compose.yml @@ -34,13 +34,13 @@ services: # 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 8470698..e76a0e7 100644 --- a/srcs/requirements/mariadb/Dockerfile +++ b/srcs/requirements/mariadb/Dockerfile @@ -1,11 +1,15 @@ FROM debian:buster -RUN apt update && apt install -y mariadb-client mariadb-server +ARG DEBIAN_FRONTEND=noninteractive -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;" +RUN apt update && \ + apt install -y mariadb-client mariadb-server && \ + rm -rf /var/lib/apt/lists/* && \ + \ + service mysql start && \ + mariadb --execute="create database db_hugo_test;" && \ + mariadb --execute="create user 'u_hugo_test'@'localhost' identified by 'hello';" && \ + 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 851c0ca..b6be10c 100644 --- a/srcs/requirements/nginx/Dockerfile +++ b/srcs/requirements/nginx/Dockerfile @@ -1,20 +1,10 @@ -# alpine : -FROM alpine:3.15 -# debian : -#FROM debian:buster +FROM debian:buster -# alpine : -RUN apk add nginx openssl -# debian : -#RUN apt update && apt install -y nginx openssl && rm -rf /var/lib/apt/lists/* +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 \ @@ -31,9 +21,6 @@ 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