there is a map with a marker, and the docker don't generate a new certificate all the time
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -49,3 +49,5 @@ Thumbs.db
|
||||
*.wmv
|
||||
*.iso
|
||||
|
||||
# ssl certificates
|
||||
ssl/
|
||||
|
||||
19
Makefile
19
Makefile
@@ -24,9 +24,10 @@ RESET = "\e[0m"
|
||||
|
||||
COMPOSE = ./srcs/docker-compose.yml
|
||||
|
||||
VOLUME_PATH = $(shell grep -w "MAP_VOLUMES" ./srcs/.env | cut -d "=" -f 2)
|
||||
VOLUMES_D = $(VOLUME_PATH)/wp_volume \
|
||||
$(VOLUME_PATH)/db_volume
|
||||
VOLUMES_D = $(shell grep "^HOST_VOLUME" ./srcs/.env | cut -d "=" -f 2)
|
||||
#VOLUME_PATH = $(shell grep "^HOST_VOLUME" ./srcs/.env | cut -d "=" -f 2)
|
||||
#VOLUMES_D = $(VOLUME_PATH)/wp_volume \
|
||||
# $(VOLUME_PATH)/db_volume
|
||||
WP_URL = $(shell grep "WP_URL" ./srcs/.env | cut -d "=" -f 2)
|
||||
|
||||
# list of running containers, see : https://stackoverflow.com/questions/10024279/how-to-use-shell-commands-in-makefile
|
||||
@@ -37,18 +38,18 @@ VOLUMES = $(shell docker volume ls -q)
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||
|
||||
all: build up
|
||||
all: volumes build up
|
||||
|
||||
volumes:
|
||||
mkdir -p $(VOLUMES_D)
|
||||
|
||||
build:
|
||||
- if ! grep "127.0.0.1 ${WP_URL}" /etc/hosts 2> /dev/null; then \
|
||||
- if ! grep "127.0.0.1 $(WP_URL)" /etc/hosts 2> /dev/null; then \
|
||||
bash -c 'echo -e "\n# adding for inception (you can delete it)\n127.0.0.1 $(WP_URL)" >> /etc/hosts'; \
|
||||
fi
|
||||
docker-compose -f $(COMPOSE) build
|
||||
|
||||
up: volumes
|
||||
up:
|
||||
docker-compose -f $(COMPOSE) up -d
|
||||
|
||||
down:
|
||||
@@ -86,8 +87,8 @@ re: fclean all
|
||||
|
||||
# !! remove everything everything
|
||||
erase_v:
|
||||
- rm -rf ${VOLUMES_D}
|
||||
hard: erase_v re
|
||||
- rm -rf $(VOLUMES_D)
|
||||
new: erase_v re
|
||||
|
||||
.PHONY : all $(VOLUMES_D) build up list clean fclean re
|
||||
.PHONY : all $(VOLUMES_D) build up list clean fclean re erase_v new
|
||||
|
||||
|
||||
17
srcs/.env
17
srcs/.env
@@ -1,4 +1,8 @@
|
||||
|
||||
# NGINX SETUP
|
||||
|
||||
NG_VOLUME_CERTS=/etc/ssl
|
||||
|
||||
# MARIADB SETUP
|
||||
|
||||
DB_HOST=mariadb
|
||||
@@ -9,8 +13,8 @@ DB_PSWD="too bad you have read this now i have to erase your memory"
|
||||
# WORDPRESS SETUP
|
||||
|
||||
WP_URL=local_lejourduprof.com
|
||||
WP_DIR=/var/www/html
|
||||
WP_PLUGIN_DIR=/home/www-data/
|
||||
WP_VOLUME_DIR=/var/www/html
|
||||
WP_VOLUME_PLUGINS=/home/www-data
|
||||
WP_TITLE=title
|
||||
|
||||
WP_ADMIN=hulamy
|
||||
@@ -25,6 +29,11 @@ WP_USER_EMAIL=moehu36@42.fr
|
||||
|
||||
MAX_UPLOAD_SIZE=512
|
||||
EXECUTION_TIME=300
|
||||
MAP_VOLUMES=/home/lenovo/data/lejourduprof
|
||||
MAP_VOLUMES_PLUGINS=/home/lenovo/42/lejourduprof/srcs/plugins
|
||||
|
||||
# HOST (start with "HOST_VOLUME" for makefile)
|
||||
|
||||
HOST_VOLUME_WP=/home/lenovo/data/lejourduprof/wp_volume
|
||||
HOST_VOLUME_DB=/home/lenovo/data/lejourduprof/db_volume
|
||||
HOST_VOLUME_PLUGINS=/home/lenovo/42/lejourduprof/srcs/plugins
|
||||
HOST_VOLUME_CERTS=/home/lenovo/42/lejourduprof/srcs/requirements/nginx/conf/ssl
|
||||
|
||||
|
||||
@@ -22,15 +22,18 @@ services:
|
||||
- inception
|
||||
ports:
|
||||
- "443:443"
|
||||
#- "80:80"
|
||||
volumes:
|
||||
- wp_volume:${WP_DIR}
|
||||
- wp_plugins:${WP_PLUGIN_DIR}
|
||||
- wp_volume:${WP_VOLUME_DIR}
|
||||
- wp_plugins:${WP_VOLUME_PLUGINS}
|
||||
- ng_certs:${NG_VOLUME_CERTS}
|
||||
build:
|
||||
context: ./requirements/nginx
|
||||
args:
|
||||
- WP_URL=${WP_URL}
|
||||
- MAX_UPLOAD_SIZE=${MAX_UPLOAD_SIZE}
|
||||
- WP_VOLUME_DIR=${WP_VOLUME_DIR}
|
||||
- WP_VOLUME_PLUGINS=${WP_VOLUME_PLUGINS}
|
||||
- NG_VOLUME_CERTS=${NG_VOLUME_CERTS}
|
||||
image: nginx
|
||||
container_name: nginx_container
|
||||
depends_on:
|
||||
@@ -65,12 +68,13 @@ services:
|
||||
networks:
|
||||
- inception
|
||||
volumes:
|
||||
- wp_volume:${WP_DIR}
|
||||
- wp_plugins:${WP_PLUGIN_DIR}
|
||||
- wp_volume:${WP_VOLUME_DIR}
|
||||
- wp_plugins:${WP_VOLUME_PLUGINS}
|
||||
build:
|
||||
context: ./requirements/wordpress
|
||||
args:
|
||||
- WP_DIR=${WP_DIR}
|
||||
- WP_VOLUME_DIR=${WP_VOLUME_DIR}
|
||||
- WP_VOLUME_PLUGINS=${WP_VOLUME_PLUGINS}
|
||||
- MAX_UPLOAD_SIZE=${MAX_UPLOAD_SIZE}
|
||||
- EXECUTION_TIME=${EXECUTION_TIME}
|
||||
image: wordpress
|
||||
@@ -81,24 +85,30 @@ services:
|
||||
|
||||
# specify path to named volumes : https://docs.docker.com/compose/compose-file/compose-file-v3/#volume-configuration-reference
|
||||
volumes:
|
||||
wp_volume:
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: none
|
||||
o: "bind"
|
||||
device: ${MAP_VOLUMES}/wp_volume
|
||||
wp_plugins:
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: none
|
||||
o: "bind"
|
||||
device: ${MAP_VOLUMES_PLUGINS}
|
||||
db_volume:
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: none
|
||||
o: "bind"
|
||||
device: ${MAP_VOLUMES}/db_volume
|
||||
device: ${HOST_VOLUME_DB}
|
||||
wp_volume:
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: none
|
||||
o: "bind"
|
||||
device: ${HOST_VOLUME_WP}
|
||||
wp_plugins:
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: none
|
||||
o: "bind"
|
||||
device: ${HOST_VOLUME_PLUGINS}
|
||||
ng_certs:
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: none
|
||||
o: "bind"
|
||||
device: ${HOST_VOLUME_CERTS}
|
||||
|
||||
networks:
|
||||
inception:
|
||||
|
||||
1
srcs/plugins/google_map/google_map
Symbolic link
1
srcs/plugins/google_map/google_map
Symbolic link
@@ -0,0 +1 @@
|
||||
/home/www-data//google_map
|
||||
@@ -56,6 +56,7 @@ function my_init_script() {
|
||||
wp_enqueue_script('my_script', $script_path, array('jquery'));
|
||||
$style_path = plugins_url('style.css', __FILE__);
|
||||
wp_enqueue_style('my_style', $style_path);
|
||||
console_log("urlencode : " . urlencode("128 rue de la croix nivert, paris"));
|
||||
}
|
||||
|
||||
function show_google_map() {
|
||||
@@ -65,7 +66,7 @@ function show_google_map() {
|
||||
$GoogleMap_zoom = get_option('map_zoom_value');
|
||||
//src="https://maps.googleapis.com/maps/api/geocode/json?address=paris&key=AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE
|
||||
?>
|
||||
<script async defer
|
||||
<script
|
||||
src="http://maps.googleapis.com/maps/api/js?&sensor=false?&key=AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE">
|
||||
</script>
|
||||
<div class="latitude"><?php echo $GoogleMap_Latitude; ?></div>
|
||||
|
||||
1
srcs/plugins/map_prof/map_prof
Symbolic link
1
srcs/plugins/map_prof/map_prof
Symbolic link
@@ -0,0 +1 @@
|
||||
/home/www-data//map_prof
|
||||
31
srcs/plugins/map_prof/map_prof.php
Executable file → Normal file
31
srcs/plugins/map_prof/map_prof.php
Executable file → Normal file
@@ -1,8 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* @package map_prof
|
||||
* @version 1.0.0
|
||||
*/
|
||||
/*
|
||||
Plugin Name: map_prof
|
||||
Plugin URI:
|
||||
@@ -12,6 +8,12 @@ Version: 1.0.0
|
||||
Author URI:
|
||||
*/
|
||||
|
||||
add_action( 'init', 'my_init_script' );
|
||||
function my_init_script() {
|
||||
$style_path = plugins_url('style.css', __FILE__);
|
||||
wp_enqueue_style('my_style', $style_path);
|
||||
}
|
||||
|
||||
// if bock theme : https://wordpress.org/support/topic/twenty-twenty-two-cpt-template-error-theme-without-header-is-deprecated/
|
||||
function add_map_api(){
|
||||
?>
|
||||
@@ -43,7 +45,7 @@ function print_content($content){
|
||||
|
||||
// print only on the page 'map', and other conditions
|
||||
// https://developer.wordpress.org/reference/hooks/the_content/
|
||||
if (!( is_page('map') && in_the_loop() && is_main_query() ))
|
||||
if (!( is_page('map_prof') && in_the_loop() && is_main_query() ))
|
||||
return $content;
|
||||
|
||||
// https://developer.wordpress.org/reference/functions/get_posts/
|
||||
@@ -90,9 +92,24 @@ function print_content($content){
|
||||
// $content .= "</p>";
|
||||
//}
|
||||
|
||||
//$content .= "<div id='map'><p>OSM map 2</p></div>";
|
||||
$content .= '<div id="map"></div>';
|
||||
$content .= '<script>
|
||||
function initMap() {
|
||||
var location = {lat: 38.8833, lng: -77.0167};
|
||||
var map = new google.maps.Map(document.getElementById("map"), {
|
||||
zoom: 12,
|
||||
center: location
|
||||
});
|
||||
var marker = new google.maps.Marker({
|
||||
position: location,
|
||||
map: map
|
||||
});
|
||||
}
|
||||
</script>';
|
||||
$content .= '<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE&callback=initMap"></script>';
|
||||
|
||||
return $content;
|
||||
};
|
||||
//add_action('the_content', 'print_content', 1);
|
||||
add_action('the_content', 'print_content', 1);
|
||||
|
||||
?>
|
||||
|
||||
4
srcs/plugins/map_prof/style.css
Normal file
4
srcs/plugins/map_prof/style.css
Normal file
@@ -0,0 +1,4 @@
|
||||
#map {
|
||||
height: 500px;
|
||||
width: 100%;
|
||||
}
|
||||
@@ -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