there is a map with a marker, and the docker don't generate a new certificate all the time
This commit is contained in:
@@ -1,34 +1,16 @@
|
||||
# debian -----------------------------------------------------
|
||||
|
||||
# FROM debian:buster
|
||||
#
|
||||
# # vim and bash for debug
|
||||
# RUN apt update && apt install -y \
|
||||
# mariadb-client \
|
||||
# mariadb-server \
|
||||
# vim bash \
|
||||
# && \
|
||||
# rm -rf /var/lib/apt/lists/*
|
||||
#
|
||||
# # config file .cnf :
|
||||
# COPY ./conf/50-server.cnf.debian /etc/mysql/mariadb.conf.d/50-server.cnf
|
||||
FROM alpine:3.15
|
||||
|
||||
# alpine -----------------------------------------------------
|
||||
# vim and bash for debug
|
||||
RUN apk update && apk add \
|
||||
mariadb \
|
||||
mariadb-client \
|
||||
vim bash \
|
||||
&& \
|
||||
rm -rf /var/cache/apk*
|
||||
|
||||
FROM alpine:3.15
|
||||
|
||||
# vim and bash for debug
|
||||
RUN apk update && apk add \
|
||||
mariadb \
|
||||
mariadb-client \
|
||||
vim bash \
|
||||
&& \
|
||||
rm -rf /var/cache/apk*
|
||||
|
||||
# config file .cnf :
|
||||
COPY ./conf/mariadb-server.cnf.alpine /etc/my.cnf.d/mariadb-server.cnf
|
||||
|
||||
# common -----------------------------------------------------
|
||||
# config file .cnf :
|
||||
COPY ./conf/mariadb-server.cnf.alpine /etc/my.cnf.d/mariadb-server.cnf
|
||||
|
||||
ARG DB_HOST
|
||||
ARG DB_NAME
|
||||
|
||||
@@ -16,10 +16,15 @@ COPY ./conf/inception_nginx.conf /etc/nginx/http.d/
|
||||
RUN adduser -S www-data && \
|
||||
adduser www-data www-data
|
||||
|
||||
RUN mkdir -p /var/www/html
|
||||
|
||||
ARG WP_URL
|
||||
ARG MAX_UPLOAD_SIZE
|
||||
ARG WP_VOLUME_DIR
|
||||
ARG WP_VOLUME_PLUGINS
|
||||
ARG NG_VOLUME_CERTS
|
||||
|
||||
# create and empty volumes dir
|
||||
RUN mkdir -p ${WP_VOLUME_DIR} ${WP_VOLUME_PLUGINS} ${NG_VOLUME_CERTS} && \
|
||||
rm -rf ${WP_VOLUME_DIR}/* ${WP_VOLUME_PLUGINS}/* ${NG_VOLUME_CERTS}/*
|
||||
|
||||
# replace WP_URL
|
||||
RUN sed -i "s/\${WP_URL}/${WP_URL}/g" /etc/nginx/http.d/inception_nginx.conf
|
||||
@@ -27,18 +32,15 @@ RUN sed -i "s/\${WP_URL}/${WP_URL}/g" /etc/nginx/http.d/inception_nginx.conf
|
||||
# replace max file size upload
|
||||
RUN sed -i "s/\(client_max_body_size \).*\(m;\)/\1${MAX_UPLOAD_SIZE}\2/g" /etc/nginx/nginx.conf
|
||||
|
||||
# empty /var/www/html folder to avoid it to rewrite volume
|
||||
#RUN rm -rf /var/www/html/*
|
||||
|
||||
# personalized index.html
|
||||
COPY ./conf/index.html /data/www/
|
||||
|
||||
# create ssl certificate
|
||||
RUN mkdir -p /etc/ssl/private /etc/ssl/certs
|
||||
RUN openssl req -newkey rsa:2048 -nodes -x509 -days 365 \
|
||||
-subj "/C=fr/ST=ile-de-france/L=paris/O=42/OU=inception/CN=${WP_URL}" \
|
||||
-keyout /etc/ssl/private/${WP_URL}.key \
|
||||
-out /etc/ssl/certs/${WP_URL}.crt
|
||||
COPY ./conf/ssl ${NG_VOLUME_CERTS}
|
||||
RUN if [ -z "$(ls -A ${NG_VOLUME_CERTS} 2>/dev/null)" ]; then \
|
||||
mkdir ${NG_VOLUME_CERTS}/private ${NG_VOLUME_CERTS}/certs; \
|
||||
openssl req -newkey rsa:2048 -nodes -x509 -days 365 \
|
||||
-subj "/C=fr/ST=ile-de-france/L=paris/O=42/OU=inception/CN=${WP_URL}" \
|
||||
-keyout ${NG_VOLUME_CERTS}/private/${WP_URL}.key \
|
||||
-out ${NG_VOLUME_CERTS}/certs/${WP_URL}.crt; \
|
||||
fi
|
||||
|
||||
ENTRYPOINT [ "nginx", "-g", "daemon off;" ]
|
||||
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
# doc : https://nginx.org/en/docs/dirindex.html
|
||||
|
||||
# WIP redirect http to https
|
||||
#server {
|
||||
# listen 80;
|
||||
# listen [::]:80;
|
||||
# server_name _;
|
||||
# return 301 https://$host$request_uri;
|
||||
#}
|
||||
|
||||
server {
|
||||
listen 443 ssl; # for ipv4, on port 443, specifying that accepted connections should works in ssl mode
|
||||
listen [::]:443 ssl; # for ipv6
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
hello world !
|
||||
@@ -18,12 +18,13 @@ RUN rm -rf /var/lib/apt/lists/*
|
||||
COPY ./conf/www.conf /etc/php7/php-fpm.d/
|
||||
RUN mkdir /run/php/
|
||||
|
||||
ARG WP_DIR
|
||||
ARG WP_VOLUME_DIR
|
||||
ARG MAX_UPLOAD_SIZE
|
||||
ARG EXECUTION_TIME
|
||||
|
||||
# create wp directory
|
||||
RUN mkdir -p ${WP_DIR}
|
||||
# create and empty volume dir
|
||||
RUN mkdir -p ${WP_VOLUME_DIR} && \
|
||||
rm -rf ${WP_VOLUME_DIR}/*
|
||||
|
||||
# replace max file size upload and execution time
|
||||
RUN sed -i "s/\(upload_max_filesize = \).*\(M\)/\1${MAX_UPLOAD_SIZE}\2/g" /etc/php7/php.ini && \
|
||||
@@ -36,9 +37,6 @@ RUN adduser -S www-data && \
|
||||
|
||||
ENV PHP_VERSION="php-fpm7"
|
||||
|
||||
# empty /var/www/html folder to avoid it to rewrite volume
|
||||
#RUN rm -rf ${WP_DIR}/*
|
||||
|
||||
# install wp-cli : https://wp-cli.org/#installing
|
||||
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar &&\
|
||||
chmod +x wp-cli.phar && \
|
||||
|
||||
@@ -13,31 +13,31 @@ RESET="\e[0m"
|
||||
# install wordpress with cli : https://make.wordpress.org/cli/handbook/how-to-install/
|
||||
# commands : https://developer.wordpress.org/cli/commands/
|
||||
echo -e ${YELLOW}download wordpress :${RESET}
|
||||
if ! wp core version --path="${WP_DIR}" 2> /dev/null
|
||||
if ! wp core version --path="${WP_VOLUME_DIR}" 2> /dev/null
|
||||
then
|
||||
mkdir -p ${WP_DIR}
|
||||
wp core download --path="${WP_DIR}" --allow-root
|
||||
mkdir -p ${WP_VOLUME_DIR}
|
||||
wp core download --path="${WP_VOLUME_DIR}" --allow-root
|
||||
else
|
||||
echo -e ${GREEN}already there !${RESET}
|
||||
fi
|
||||
|
||||
# create config file :
|
||||
echo -e ${YELLOW}config wordpress :${RESET}
|
||||
if ! wp config path --path="${WP_DIR}" --quiet 2> /dev/null
|
||||
if ! wp config path --path="${WP_VOLUME_DIR}" --quiet 2> /dev/null
|
||||
then
|
||||
wp config create \
|
||||
--dbhost="${DB_HOST}" \
|
||||
--dbname="${DB_NAME}" \
|
||||
--dbuser="${DB_USER}" \
|
||||
--dbpass="${DB_PSWD}" \
|
||||
--path="${WP_DIR}" --allow-root
|
||||
--path="${WP_VOLUME_DIR}" --allow-root
|
||||
else
|
||||
echo -e ${GREEN}already configured !${RESET}
|
||||
fi
|
||||
|
||||
# install wordpress :
|
||||
echo -e ${YELLOW}install wordpress :${RESET}
|
||||
if ! wp core is-installed --path="${WP_DIR}" 2> /dev/null
|
||||
if ! wp core is-installed --path="${WP_VOLUME_DIR}" 2> /dev/null
|
||||
then
|
||||
wp core install \
|
||||
--url="${WP_URL}" \
|
||||
@@ -46,19 +46,19 @@ then
|
||||
--admin_email="${WP_ADMIN_EMAIL}" \
|
||||
--admin_password="${WP_ADMIN_PSWD}" \
|
||||
--skip-email \
|
||||
--path="${WP_DIR}" --allow-root
|
||||
--path="${WP_VOLUME_DIR}" --allow-root
|
||||
else
|
||||
echo -e ${GREEN}already installed !${RESET}
|
||||
fi
|
||||
|
||||
# create user :
|
||||
echo -e ${YELLOW}create wordpress user :${RESET}
|
||||
if ! wp user get ${WP_USER} --path="${WP_DIR}" --field=login 2> /dev/null
|
||||
if ! wp user get ${WP_USER} --path="${WP_VOLUME_DIR}" --field=login 2> /dev/null
|
||||
then
|
||||
wp user create \
|
||||
"${WP_USER}" "${WP_USER_EMAIL}" \
|
||||
--user_pass="${WP_USER_PSWD}" \
|
||||
--path="${WP_DIR}" --allow-root
|
||||
--path="${WP_VOLUME_DIR}" --allow-root
|
||||
else
|
||||
echo -e ${GREEN}already created !${RESET}
|
||||
fi
|
||||
@@ -68,7 +68,11 @@ chown -R www-data:www-data /var/www/*
|
||||
chmod 755 -R /var/www/*
|
||||
|
||||
# symlinks for folders found in host plugins/
|
||||
# todo
|
||||
plugins=$(ls ${WP_VOLUME_PLUGIN})
|
||||
for dir in $plugins; do
|
||||
ln -s ${WP_VOLUME_PLUGIN}/$dir ${WP_VOLUME_DIR}/wp-content/plugins/$dir
|
||||
done
|
||||
|
||||
|
||||
exec "${PHP_VERSION}" -FR
|
||||
|
||||
|
||||
Reference in New Issue
Block a user