wordpress works now with :

+ volumes in mariadb container
+ db pswd in quotes
+ somes other settings
This commit is contained in:
hugo gogo
2022-09-21 18:10:03 +02:00
parent ef8ce69dad
commit 0603616d3e
9 changed files with 108 additions and 81 deletions

View File

@@ -30,6 +30,7 @@
# common -----------------------------------------------------
ARG DB_HOST
ARG DB_NAME
ARG DB_USER
ARG DB_PSWD
@@ -41,9 +42,10 @@ RUN mysql_install_db --user=mysql --ldata=/var/lib/mysql && \
# configure wp database
COPY ./conf/create_db.sql /usr/bin/create_db.sql
RUN sed -i "s/\${DB_NAME}/${DB_NAME}/g" /usr/bin/create_db.sql
RUN sed -i "s/\${DB_USER}/${DB_USER}/g" /usr/bin/create_db.sql
RUN sed -i "s/\${DB_PSWD}/${DB_PSWD}/g" /usr/bin/create_db.sql
RUN sed -i "s/\${DB_HOST}/${DB_HOST}/g" /usr/bin/create_db.sql && \
sed -i "s/\${DB_NAME}/${DB_NAME}/g" /usr/bin/create_db.sql && \
sed -i "s/\${DB_USER}/${DB_USER}/g" /usr/bin/create_db.sql && \
sed -i "s/\${DB_PSWD}/${DB_PSWD}/g" /usr/bin/create_db.sql
ENTRYPOINT [ "mysqld", "--user=mysql", "--init-file=/usr/bin/create_db.sql" ]

View File

@@ -1,5 +1,5 @@
USE mysql;
CREATE DATABASE IF NOT EXISTS ${DB_NAME};
CREATE USER IF NOT EXISTS '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PSWD}';
GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO '${DB_USER}'@'localhost' with grant option;
CREATE USER IF NOT EXISTS '${DB_USER}'@'%' IDENTIFIED BY '${DB_PSWD}';
GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO '${DB_USER}'@'%' with grant option;

View File

@@ -1,42 +1,43 @@
# debian (~ 180s) --------------------------------------------
FROM debian:buster
# vim for debug
RUN apt update && apt install -y \
nginx openssl \
vim \
&& \
rm -rf /var/lib/apt/lists/*
# nginx conf
COPY ./conf/nginx.conf.debian /etc/nginx/nginx.conf
COPY ./conf/inception_nginx.conf /etc/nginx/conf.d/
# FROM debian:buster
#
# # vim for debug
# RUN apt update && apt install -y \
# nginx openssl \
# vim \
# && \
# rm -rf /var/lib/apt/lists/*
#
# # nginx conf
# COPY ./conf/nginx.conf.debian /etc/nginx/nginx.conf
# COPY ./conf/inception_nginx.conf /etc/nginx/conf.d/
# alpine (~ 45s) ---------------------------------------------
# FROM alpine:3.15
#
# # vim and bash for debug
# RUN apk update && apk add \
# nginx openssl \
# vim bash \
# && \
# rm -rf /var/cache/apk*
#
# # nginx conf
# COPY ./conf/nginx.conf.alpine /etc/nginx/nginx.conf
# COPY ./conf/inception_nginx.conf /etc/nginx/http.d/
#
# # create user www-data and assign it to group www-data
# RUN adduser -S www-data && \
# adduser www-data www-data
#
# RUN mkdir -p /var/www/html
FROM alpine:3.15
# vim and bash for debug
RUN apk update && apk add \
nginx openssl \
vim bash \
&& \
rm -rf /var/cache/apk*
# nginx conf
COPY ./conf/nginx.conf.alpine /etc/nginx/nginx.conf
COPY ./conf/inception_nginx.conf /etc/nginx/http.d/
# create user www-data and assign it to group www-data
RUN adduser -S www-data && \
adduser www-data www-data
RUN mkdir -p /var/www/html
# common -----------------------------------------------------
RUN rm -rf /var/www/html/*
# 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/

View File

@@ -3,6 +3,11 @@
# user :
# < user www-data
# > user nginx
#
# protocols :
#
# < ssl_protocols TLSv1.2 TLSv1.3;
# > ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
# /etc/nginx/nginx.conf
@@ -59,7 +64,7 @@ http {
# Enables the specified protocols. Default is TLSv1 TLSv1.1 TLSv1.2.
# TIP: If you're not obligated to support ancient clients, remove TLSv1.1.
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_protocols TLSv1.2 TLSv1.3;
# Path of the file with Diffie-Hellman parameters for EDH ciphers.
# TIP: Generate with: `openssl dhparam -out /etc/ssl/nginx/dh2048.pem 2048`

View File

@@ -1,53 +1,58 @@
# debian -----------------------------------------------------
FROM debian:buster
# bash and vim for debug
RUN apt update && apt install -y \
php7.3 \
php7.3-fpm \
php7.3-mysqli \
curl \
bash vim
RUN rm -rf /var/lib/apt/lists/*
# fpm config
COPY ./conf/www.conf /etc/php/7.3/fpm/pool.d/
RUN mkdir /run/php/
ENV PHP_VERSION="php-fpm7.3"
# alpine -----------------------------------------------------
# FROM alpine:3.15
# FROM debian:buster
#
# # bash and vim for debug
# RUN apk update && apk add \
# php7 \
# php7-fpm \
# php7-mysqli \
# php7-phar \
# php7-json \
# RUN apt update && apt install -y \
# php7.3 \
# php7.3-fpm \
# php7.3-mysqli \
# mariadb-client \
# curl \
# bash vim
# RUN rm -rf /var/lib/apt/lists/*
#
# # fpm config
# COPY ./conf/www.conf /etc/php7/php-fpm.d/
# COPY ./conf/www.conf /etc/php/7.3/fpm/pool.d/
# RUN mkdir /run/php/
#
# # create wp directory
# ARG WP_DIR
# RUN mkdir -p ${WP_DIR}
#
# # create www-data user and add to group
# RUN adduser -S www-data && \
# adduser www-data www-data
#
# ENV PHP_VERSION="php-fpm7"
# ENV PHP_VERSION="php-fpm7.3"
# alpine -----------------------------------------------------
FROM alpine:3.15
# bash and vim for debug
RUN apk update && apk add \
php7 \
php7-fpm \
php7-mysqli \
php7-phar \
php7-json \
mariadb-client \
curl \
bash vim
RUN rm -rf /var/lib/apt/lists/*
# fpm config
COPY ./conf/www.conf /etc/php7/php-fpm.d/
RUN mkdir /run/php/
# create wp directory
ARG WP_DIR
RUN mkdir -p ${WP_DIR}
# create www-data user and add to group
RUN adduser -S www-data && \
adduser www-data www-data
ENV PHP_VERSION="php-fpm7"
# common -----------------------------------------------------
# empty /var/www/html folder to avoid it to rewrite volume
#RUN rm -rf /var/www/html/*
# 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 && \

View File

@@ -6,10 +6,10 @@ wp core download --path="${WP_DIR}" --allow-root
# create config file :
wp config create \
--dbhost=mariadb \
--dbhost="${DB_HOST}" \
--dbname="${DB_NAME}" \
--dbuser="${DB_USER}" \
--dbpass="${DB_PASS}" \
--dbpass="${DB_PSWD}" \
--path="${WP_DIR}" --allow-root
# install wordpress :
@@ -32,5 +32,5 @@ wp user create \
chown -R www-data:www-data /var/www/*
chmod 755 -R /var/www/*
exec ${PHP_VERSION} -FR
exec "${PHP_VERSION}" -FR