wp fail certainly because docker build have no access to docker network
This commit is contained in:
3
Makefile
3
Makefile
@@ -26,7 +26,8 @@ COMPOSE = ./srcs/docker-compose.yml
|
||||
|
||||
IMAGES = test \
|
||||
nginx \
|
||||
mariadb
|
||||
mariadb \
|
||||
wordpress
|
||||
|
||||
HOME_D = $(shell echo $(HOME))
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
- [docker CMD vs ENTRYPOINT](https://phoenixnap.com/kb/docker-cmd-vs-entrypoint)
|
||||
- [use env variable with compose](https://docs.docker.com/compose/environment-variables/)
|
||||
- [using DEBIAN_FRONTEND=noninteractive disouraged in dockerfile](https://bobcares.com/blog/debian_frontendnoninteractive-docker/)
|
||||
- [docker network](https://docs.docker.com/network/)
|
||||
|
||||
###### docker pid 1
|
||||
- nginx by default will create some child process (a master and some workers), then it quits (doc ?)
|
||||
|
||||
13
srcs/.env
13
srcs/.env
@@ -6,3 +6,16 @@
|
||||
DB_NAME=db_wp_inception
|
||||
DB_USER=user_wp_inception
|
||||
DB_PSWD="if you read this i will have to erase your memory"
|
||||
|
||||
## TMP MARIADB SETUP
|
||||
DB_NAME_TMP=db_wp_inception_tmp
|
||||
DB_USER_TMP=user_wp_inception_tmp
|
||||
DB_PSWD_TMP="if you read this i will have to erase your memory _tmp"
|
||||
|
||||
## WORDPRESS SETUP
|
||||
WP_DIR=/var/www/html
|
||||
WP_URL=hulamy.42.fr
|
||||
WP_TITLE="le blog !"
|
||||
WP_ADMIN=hulamy
|
||||
WP_ADMIN_PSWD="you shall not password !"
|
||||
WP_ADMIN_EMAIL=hulamy@42.fr
|
||||
|
||||
@@ -38,4 +38,28 @@ services:
|
||||
- DB_PSWD=${DB_PSWD}
|
||||
image: mariadb
|
||||
container_name: mymariadb
|
||||
# ---------------------------------
|
||||
wordpress:
|
||||
#restart: on-failure
|
||||
networks:
|
||||
- inception-network
|
||||
env_file: .env
|
||||
build:
|
||||
context: ./requirements/wordpress
|
||||
args:
|
||||
- WP_DIR=${WP_DIR}
|
||||
- WP_URL=${WP_URL}
|
||||
- WP_TITLE=${WP_TITLE}
|
||||
- WP_ADMIN=${WP_ADMIN}
|
||||
- WP_ADMIN_PSWD=${WP_ADMIN_PSWD}
|
||||
- WP_ADMIN_EMAIL=${WP_ADMIN_EMAIL}
|
||||
- DB_NAME=${DB_NAME_TMP}
|
||||
- DB_USER=${DB_USER_TMP}
|
||||
- DB_PSWD=${DB_PSWD_TMP}
|
||||
image: wordpress
|
||||
container_name: mywordpress
|
||||
|
||||
networks:
|
||||
inception-network:
|
||||
driver: bridge
|
||||
|
||||
|
||||
@@ -10,15 +10,12 @@ RUN apt update && apt install -y \
|
||||
&& \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# (NOT NECESSARY : DONE BY WP)
|
||||
# configure wp database
|
||||
RUN service mysql start && \
|
||||
mariadb --execute="CREATE DATABASE ${DB_NAME};" && \
|
||||
mariadb --execute="CREATE USER '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PSWD}';" && \
|
||||
mariadb --execute="GRANT ALL PRIVILEGES ON &{DB_NAME}.* TO '${DB_USER}'@'localhost' with grant option;"
|
||||
|
||||
# alternative : (https://mariadb.com/resources/blog/how-to-install-and-run-wordpress-with-mariadb/)
|
||||
# create database new_wp;
|
||||
# grant all privileges on new_wp.* to wpuser@localhost identified by 'myp@Ssw0Rd';
|
||||
mariadb --execute="GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO '${DB_USER}'@'localhost' with grant option;"
|
||||
|
||||
CMD [ "mysqld" ]
|
||||
|
||||
|
||||
@@ -2,19 +2,31 @@ FROM debian:buster
|
||||
|
||||
RUN apt update && apt install -y \
|
||||
php7.3 \
|
||||
mariadb-client \
|
||||
curl
|
||||
|
||||
# install wp-cli : https://make.wordpress.org/cli/handbook/guides/installing/
|
||||
#RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar &&\
|
||||
# chmod +x wp-cli.phar && \
|
||||
# sudo mv wp-cli.phar /usr/local/bin/wp
|
||||
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar &&\
|
||||
chmod +x wp-cli.phar && \
|
||||
mv wp-cli.phar /usr/local/bin/wp
|
||||
|
||||
ARG WP_DIR
|
||||
ARG WP_URL
|
||||
ARG WP_TITLE
|
||||
ARG WP_ADMIN
|
||||
ARG WP_ADMIN_PSWD
|
||||
ARG WP_ADMIN_EMAIL
|
||||
|
||||
ARG DB_NAME
|
||||
ARG DB_USER
|
||||
ARG DB_PSWD
|
||||
|
||||
# install wordpress with cli : https://make.wordpress.org/cli/handbook/how-to-install/
|
||||
#RUN wp core download --path=${WP_DIR}
|
||||
RUN wp core download --path=${WP_DIR} --allow-root
|
||||
# create config file :
|
||||
#RUN wp config create --dbname=${DB_NAME} --dbuser=${DB_USER} --dbpass=${DB_PASS} --path=${WP_DIR}
|
||||
RUN wp config create --dbname=${DB_NAME} --dbuser=${DB_USER} --dbpass=${DB_PASS} --path=${WP_DIR} --allow-root
|
||||
# create db :
|
||||
#RUN wp db create --path=${WP_DIR}
|
||||
RUN service mysql start && wp db create --path=${WP_DIR} --allow-root
|
||||
# install wordpress :
|
||||
#RUN wp core install --url=${WP_URL} --title=${WP_TITLE} --admin_user=${WP_ADMIN} --admin_password=${WP_ADMIN_PSWD} --admin_email=${WP_ADMIN_EMAIL} --path=${WP_DIR}
|
||||
RUN wp core install --url=${WP_URL} --title=${WP_TITLE} --admin_user=${WP_ADMIN} --admin_password=${WP_ADMIN_PSWD} --admin_email=${WP_ADMIN_EMAIL} --path=${WP_DIR} --allow-root
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
mon_super_mot_de_passe
|
||||
Reference in New Issue
Block a user