From c0be4a912f4ea9f076645875e0f0bbdf320ceb62 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Mon, 11 Sep 2023 18:17:10 +0200 Subject: [PATCH] Implemented new upload limit --- roles/docker-wordpress/files/Dockerfile | 2 ++ roles/docker-wordpress/handlers/main.yml | 13 +++++++--- roles/docker-wordpress/tasks/main.yml | 26 +++++++++++++++---- .../templates/docker-compose.yml.j2 | 4 ++- .../docker-wordpress/templates/upload.ini.j2 | 5 ++++ roles/docker-wordpress/vars/main.yml | 2 ++ 6 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 roles/docker-wordpress/files/Dockerfile create mode 100644 roles/docker-wordpress/templates/upload.ini.j2 create mode 100644 roles/docker-wordpress/vars/main.yml diff --git a/roles/docker-wordpress/files/Dockerfile b/roles/docker-wordpress/files/Dockerfile new file mode 100644 index 00000000..ce946abc --- /dev/null +++ b/roles/docker-wordpress/files/Dockerfile @@ -0,0 +1,2 @@ +FROM wordpress +COPY upload.ini $PHP_INI_DIR/conf.d/ \ No newline at end of file diff --git a/roles/docker-wordpress/handlers/main.yml b/roles/docker-wordpress/handlers/main.yml index 5d586c31..633214f3 100644 --- a/roles/docker-wordpress/handlers/main.yml +++ b/roles/docker-wordpress/handlers/main.yml @@ -1,8 +1,15 @@ --- -- name: recreate wordpress +- name: rebuild wordpress container command: - cmd: docker-compose -p wordpress up -d --force-recreate - chdir: "{{path_docker_compose_files}}wordpress/" + cmd: docker build --no-cache -t custom_wordpress . + chdir: "{{docker_compose_wordpress_path}}" environment: COMPOSE_HTTP_TIMEOUT: 600 DOCKER_CLIENT_TIMEOUT: 600 +- name: recreate wordpress + command: + cmd: docker-compose -p wordpress up -d --force-recreate + chdir: "{{docker_compose_wordpress_path}}" + environment: + COMPOSE_HTTP_TIMEOUT: 600 + DOCKER_CLIENT_TIMEOUT: 600 \ No newline at end of file diff --git a/roles/docker-wordpress/tasks/main.yml b/roles/docker-wordpress/tasks/main.yml index 2e282b06..5ca91db2 100644 --- a/roles/docker-wordpress/tasks/main.yml +++ b/roles/docker-wordpress/tasks/main.yml @@ -5,18 +5,34 @@ - name: configure wordpress nginx configurations vars: - client_max_body_size: "2M" + client_max_body_size: "{{wordpress_max_upload_size}}" domain: "{{item}}" template: src=roles/docker-reverse-proxy/templates/domain.conf.j2 dest=/etc/nginx/conf.d/{{ item }}.conf loop: "{{domains}}" notify: restart nginx -- name: "create {{path_docker_compose_files}}wordpress/" +- name: "create {{docker_compose_wordpress_path}}" file: - path: "{{path_docker_compose_files}}wordpress/" + path: "{{docker_compose_wordpress_path}}" state: directory mode: 0755 -- name: add docker-compose.yml - template: src=docker-compose.yml.j2 dest={{path_docker_compose_files}}wordpress/docker-compose.yml +- name: "Transfering upload.ini to {{docker_compose_wordpress_path}}" + template: + src: upload.ini.j2 + dest: "{{docker_compose_wordpress_path}}upload.ini" + notify: + - recreate wordpress + - rebuild wordpress container + +- name: "Transfering Dockerfile to {{docker_compose_wordpress_path}}" + copy: + src: Dockerfile + dest: "{{docker_compose_wordpress_path}}Dockerfile" + notify: + - recreate wordpress + - rebuild wordpress container + +- name: "add docker-compose.yml to {{docker_compose_wordpress_path}}" + template: src=docker-compose.yml.j2 dest={{docker_compose_wordpress_path}}docker-compose.yml notify: recreate wordpress diff --git a/roles/docker-wordpress/templates/docker-compose.yml.j2 b/roles/docker-wordpress/templates/docker-compose.yml.j2 index 689c16c1..dc8f9ec9 100644 --- a/roles/docker-wordpress/templates/docker-compose.yml.j2 +++ b/roles/docker-wordpress/templates/docker-compose.yml.j2 @@ -4,7 +4,9 @@ services: application: logging: driver: journald - image: wordpress + image: custom_wordpress + build: + context: . restart: always ports: - "127.0.0.1:{{http_port}}:80" diff --git a/roles/docker-wordpress/templates/upload.ini.j2 b/roles/docker-wordpress/templates/upload.ini.j2 new file mode 100644 index 00000000..cab4cfc4 --- /dev/null +++ b/roles/docker-wordpress/templates/upload.ini.j2 @@ -0,0 +1,5 @@ +file_uploads = On +memory_limit = {{wordpress_max_upload_size}} +upload_max_filesize = {{wordpress_max_upload_size}} +post_max_size = {{wordpress_max_upload_size}} +max_execution_time = 300 \ No newline at end of file diff --git a/roles/docker-wordpress/vars/main.yml b/roles/docker-wordpress/vars/main.yml new file mode 100644 index 00000000..9be75913 --- /dev/null +++ b/roles/docker-wordpress/vars/main.yml @@ -0,0 +1,2 @@ +docker_compose_wordpress_path: "{{path_docker_compose_files}}wordpress/" +wordpress_max_upload_size: "64M"