wordpress works now with :
+ volumes in mariadb container + db pswd in quotes + somes other settings
This commit is contained in:
@@ -5,9 +5,11 @@ LOGIN=$USER
|
||||
|
||||
# MARIADB SETUP
|
||||
|
||||
DB_HOST=mariadb
|
||||
DB_NAME=db_wp_inception
|
||||
DB_USER=user_wp_inception
|
||||
DB_PSWD="if you read this i will have to erase your memory"
|
||||
#ROOT_PSWD="root passphrase"
|
||||
|
||||
# WORDPRESS SETUP
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ services:
|
||||
ports:
|
||||
- "443:443"
|
||||
# - "80:80"
|
||||
volumes:
|
||||
- wp_volume:/var/www/html
|
||||
build: ./requirements/nginx
|
||||
image: nginx
|
||||
container_name: nginx_container
|
||||
@@ -28,14 +30,20 @@ services:
|
||||
env_file: .env
|
||||
networks:
|
||||
- inception
|
||||
# volumes:
|
||||
# - db_volume:/var/lib/mysql
|
||||
volumes:
|
||||
- db_volume:/var/lib/mysql
|
||||
build:
|
||||
context: ./requirements/mariadb
|
||||
args:
|
||||
- DB_HOST=${DB_HOST}
|
||||
- DB_NAME=${DB_NAME}
|
||||
- DB_USER=${DB_USER}
|
||||
- DB_PSWD=${DB_PSWD}
|
||||
healthcheck:
|
||||
test: mariadb -h ${DB_HOST} -u ${DB_USER} -p"${DB_PSWD}" -e exit 2> /dev/null
|
||||
interval: 1s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
image: mariadb
|
||||
container_name: mariadb_container
|
||||
# ---------------------------------
|
||||
@@ -44,8 +52,8 @@ services:
|
||||
env_file: ./.env
|
||||
networks:
|
||||
- inception
|
||||
# volumes:
|
||||
# - wp_volume:/var/www/html
|
||||
volumes:
|
||||
- wp_volume:/var/www/html
|
||||
build:
|
||||
context: ./requirements/wordpress
|
||||
args:
|
||||
@@ -54,7 +62,7 @@ services:
|
||||
container_name: wordpress_container
|
||||
depends_on:
|
||||
mariadb:
|
||||
condition: service_started
|
||||
condition: service_healthy
|
||||
|
||||
# specify path to named volumes : https://docs.docker.com/compose/compose-file/compose-file-v3/#volume-configuration-reference
|
||||
volumes:
|
||||
|
||||
@@ -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" ]
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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/
|
||||
|
||||
@@ -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`
|
||||
|
||||
@@ -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 && \
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user