prevent plugin volume to have ownerships overwritten by docker

This commit is contained in:
asus
2024-02-06 15:46:43 +01:00
parent 00473e1288
commit 24aac70ac8
4 changed files with 27 additions and 4 deletions

View File

@@ -33,7 +33,8 @@ SOURCE_ENV := . $(ENV_PATH)
# list of volumes
VOLUME_ENV := set | grep "^HOST_VOLUME_" | cut -d "=" -f 2
VOLUMES_D = $(shell $(SOURCE_ENV) ; $(VOLUME_ENV) )
VOLUMES_D += $(shell $(SOURCE_ENV) ; echo $$HOST_VOLUMES_DIR )
ERASE_VOLUMES_D = $(shell $(SOURCE_ENV) ; echo $$HOST_VOLUMES_DIR )
VOLUME_PLUGINS_D = $(shell $(SOURCE_ENV) ; echo $$HOST_VOLUME_PLUGINS )
# url for wordpress, use in makefile to change local
WP_URL = $(shell $(SOURCE_ENV) ; echo $$WP_URL )
WP_COMPLETE_URL = $(shell $(SOURCE_ENV) ; echo $$WP_COMPLETE_URL )
@@ -88,7 +89,11 @@ build_logs:
# before starting the containers with up,
# creating a README.md file inside some binded volumes dir
# to avoid them having their ownership overwritten by docker
up:
echo "this is a binded docker volume for plugins" >> ${VOLUME_PLUGINS_D}/README.md
docker compose -f $(COMPOSE_FILE) up -d
@echo $(B_PURPLE)"you can now connect at "$(B_YELLOW)"https://$(WP_COMPLETE_URL)"$(B_PURPLE)" or 127.0.0.1"$(RESET)
down:
@@ -128,11 +133,11 @@ re: fclean all
# !! remove everything everything
# !! remove everything, also local volumes
# execpt the plugin volume
erase_volume:
- rm -rf $(VOLUMES_D)
- rm -rf $(ERASE_VOLUMES_D)
erase: fclean erase_volume
- rm -rf $(VOLUMES_D)
new: erase all

View File

@@ -24,6 +24,7 @@ services:
- WP_URL=${WP_URL}
- SERVER_MAX_UPLOAD_SIZE=${SERVER_MAX_UPLOAD_SIZE}
- WP_VOLUME_DIR=${WP_VOLUME_DIR}
- WP_VOLUME_PLUGINS=${WP_VOLUME_PLUGINS}
- NG_CERTS_DIR=${NG_CERTS_DIR}
image: nginx
container_name: nginx_container
@@ -64,6 +65,8 @@ services:
build:
context: ./requirements/wordpress
args:
- WP_VOLUME_DIR=${WP_VOLUME_DIR}
- WP_VOLUME_PLUGINS=${WP_VOLUME_PLUGINS}
- SERVER_MAX_UPLOAD_SIZE=${SERVER_MAX_UPLOAD_SIZE}
- SERVER_EXECUTION_TIME=${SERVER_EXECUTION_TIME}
image: wordpress

View File

@@ -23,9 +23,16 @@ RUN adduser -S www-data && \
# ARG variables are not persistent after the build process, in opposite to ENV
ARG WP_URL
ARG WP_VOLUME_DIR
ARG WP_VOLUME_PLUGINS
ARG NG_CERTS_DIR
ARG SERVER_MAX_UPLOAD_SIZE
# IS IT USEFUL ?
# # create and empty volumes dir
# RUN mkdir -p ${WP_VOLUME_DIR} ${WP_VOLUME_PLUGINS} && \
# rm -rf ${WP_VOLUME_DIR}/* ${WP_VOLUME_PLUGINS}/*
# replace WP_URL
RUN sed -i "s/\${WP_URL}/${WP_URL}/g" /etc/nginx/http.d/nginx_http_server.conf
# replace max file size upload

View File

@@ -26,9 +26,17 @@ RUN rm -rf /var/lib/apt/lists/*
COPY ./conf/www.conf /etc/php7/php-fpm.d/
RUN mkdir /run/php/
ARG WP_VOLUME_DIR
ARG WP_VOLUME_PLUGINS
ARG SERVER_MAX_UPLOAD_SIZE
ARG SERVER_EXECUTION_TIME
# IS IT USEFUL ?
# # create and empty volumes dir
# RUN mkdir -p ${WP_VOLUME_DIR} ${WP_VOLUME_PLUGINS} && \
# rm -rf ${WP_VOLUME_DIR}/* ${WP_VOLUME_PLUGINS}/*
# replace max file size upload and execution time
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${SERVER_MAX_UPLOAD_SIZE}\2/g" /etc/php7/php.ini && \