- changed volumes to be local to the repo

- added volumes/ dir in gitignore
This commit is contained in:
asus
2024-02-05 16:15:45 +01:00
parent 56a69c5520
commit f43de228c6
5 changed files with 24 additions and 21 deletions

1
.gitignore vendored
View File

@@ -54,3 +54,4 @@ ssl/
# other # other
.env .env
volumes/

View File

@@ -21,7 +21,7 @@ services:
context: ./requirements/nginx context: ./requirements/nginx
args: args:
- WP_URL=${WP_URL} - WP_URL=${WP_URL}
- MAX_UPLOAD_SIZE=${MAX_UPLOAD_SIZE} - SERVER_MAX_UPLOAD_SIZE=${SERVER_MAX_UPLOAD_SIZE}
- WP_VOLUME_DIR=${WP_VOLUME_DIR} - WP_VOLUME_DIR=${WP_VOLUME_DIR}
- NG_VOLUME_CERTS=${NG_VOLUME_CERTS} - NG_VOLUME_CERTS=${NG_VOLUME_CERTS}
image: nginx image: nginx
@@ -36,7 +36,7 @@ services:
networks: networks:
- inception - inception
volumes: volumes:
- db_volume:/var/lib/mysql - db_volume:${DB_VOLUME_DIR}
build: build:
context: ./requirements/mariadb context: ./requirements/mariadb
args: args:
@@ -62,9 +62,8 @@ services:
build: build:
context: ./requirements/wordpress context: ./requirements/wordpress
args: args:
- WP_VOLUME_DIR=${WP_VOLUME_DIR} - SERVER_MAX_UPLOAD_SIZE=${SERVER_MAX_UPLOAD_SIZE}
- MAX_UPLOAD_SIZE=${MAX_UPLOAD_SIZE} - SERVER_EXECUTION_TIME=${SERVER_EXECUTION_TIME}
- EXECUTION_TIME=${EXECUTION_TIME}
image: wordpress image: wordpress
container_name: wordpress_container container_name: wordpress_container
depends_on: depends_on:

View File

@@ -1,9 +1,13 @@
#!/bin/bash
PROJECT_NAME="jipf" PROJECT_NAME="jipf"
PROJECT_URL="local_lejourduprof.com" PROJECT_URL="local_lejourduprof.com"
PROJECT_PORT=443 PROJECT_PORT=443
# change execution_time and max_upload_size, in wp and nginx
SERVER_EXECUTION_TIME=300
SERVER_MAX_UPLOAD_SIZE=512
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# NGINX SETUP # NGINX SETUP
@@ -14,6 +18,7 @@ NG_VOLUME_CERTS=/etc/ssl
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# MARIADB SETUP # MARIADB SETUP
DB_VOLUME_DIR=/var/lib/mysql
DB_HOST=mariadb DB_HOST=mariadb
DB_NAME=db_wp_${PROJECT_NAME} DB_NAME=db_wp_${PROJECT_NAME}
DB_USER=user_wp_${PROJECT_NAME} DB_USER=user_wp_${PROJECT_NAME}
@@ -37,10 +42,6 @@ WP_ADMIN=admin
WP_ADMIN_PSWD="you shall not password !" WP_ADMIN_PSWD="you shall not password !"
WP_ADMIN_EMAIL=admin@email.fr WP_ADMIN_EMAIL=admin@email.fr
# change execution_time and max_upload_size in wordpress
EXECUTION_TIME=300
MAX_UPLOAD_SIZE=512
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# VOLUMES # VOLUMES
@@ -71,8 +72,11 @@ MAX_UPLOAD_SIZE=512
# - and output : "/home/username" # - and output : "/home/username"
# - because "~username" expand in the home (~) directory of given user # - because "~username" expand in the home (~) directory of given user
# https://stackoverflow.com/questions/77088135/makefile-subst-doesnt-use-make-variable-as-expected # https://stackoverflow.com/questions/77088135/makefile-subst-doesnt-use-make-variable-as-expected
HOME_PATH=$(eval echo "~$SUDO_USER") HOST_HOME_PATH=$(eval echo "~$SUDO_USER")
HOST_VOLUME_WP=${HOME_PATH}/data/lejourduprof/wp_volume # makefile will create the volumes folders
HOST_VOLUME_DB=${HOME_PATH}/data/lejourduprof/db_volume # we put them inside a volumes/ dir, sibling to the srcs/ dir
HOST_VOLUMES_DIR=$(realpath ${DIR_PATH}/../volumes)
HOST_VOLUME_WP=${HOST_VOLUMES_DIR}/wp_volume
HOST_VOLUME_DB=${HOST_VOLUMES_DIR}/db_volume

View File

@@ -22,14 +22,14 @@ RUN adduser -S www-data && \
# ARG variables are not persistent after the build process, in opposite to ENV # ARG variables are not persistent after the build process, in opposite to ENV
ARG WP_URL ARG WP_URL
ARG MAX_UPLOAD_SIZE
ARG WP_VOLUME_DIR ARG WP_VOLUME_DIR
ARG NG_VOLUME_CERTS ARG NG_VOLUME_CERTS
ARG SERVER_MAX_UPLOAD_SIZE
# replace WP_URL # replace WP_URL
RUN sed -i "s/\${WP_URL}/${WP_URL}/g" /etc/nginx/http.d/nginx_http_server.conf RUN sed -i "s/\${WP_URL}/${WP_URL}/g" /etc/nginx/http.d/nginx_http_server.conf
# replace max file size upload # replace max file size upload
RUN sed -i "s/\(client_max_body_size \).*\(m;\)/\1${MAX_UPLOAD_SIZE}\2/g" /etc/nginx/nginx.conf RUN sed -i "s/\(client_max_body_size \).*\(m;\)/\1${SERVER_MAX_UPLOAD_SIZE}\2/g" /etc/nginx/nginx.conf
# create ssl certificates # create ssl certificates
# command openssl : # command openssl :

View File

@@ -26,14 +26,13 @@ RUN rm -rf /var/lib/apt/lists/*
COPY ./conf/www.conf /etc/php7/php-fpm.d/ COPY ./conf/www.conf /etc/php7/php-fpm.d/
RUN mkdir /run/php/ RUN mkdir /run/php/
ARG WP_VOLUME_DIR ARG SERVER_MAX_UPLOAD_SIZE
ARG MAX_UPLOAD_SIZE ARG SERVER_EXECUTION_TIME
ARG EXECUTION_TIME
# replace max file size upload and execution time # 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 && \ RUN sed -i "s/\(upload_max_filesize = \).*\(M\)/\1${SERVER_MAX_UPLOAD_SIZE}\2/g" /etc/php7/php.ini && \
sed -i "s/\(post_max_size = \).*\(M\)/\1${MAX_UPLOAD_SIZE}\2/g" /etc/php7/php.ini && \ sed -i "s/\(post_max_size = \).*\(M\)/\1${SERVER_MAX_UPLOAD_SIZE}\2/g" /etc/php7/php.ini && \
sed -i "s/\(max_execution_time = \).*/\1${EXECUTION_TIME}/g" /etc/php7/php.ini sed -i "s/\(max_execution_time = \).*/\1${SERVER_EXECUTION_TIME}/g" /etc/php7/php.ini
# create www-data user and add to group # create www-data user and add to group
RUN adduser -S www-data && \ RUN adduser -S www-data && \