فهرست منبع

:wrench: add php-fpm docker starter

China Kassapa 7 ماه پیش
والد
کامیت
33f97ada6c

+ 1 - 0
deploy/group_vars/all.yml

@@ -11,6 +11,7 @@ app_postgresql_version: "16"
 app_open_search_version: "2.19.1"
 app_python_version: "3.13"
 app_php_version: "8.1"
+app_php_fpm_port: 9081
 app_php_memory_limit: "128M"
 app_container_prefix: "mint"
 app_consumer_loop_limit_ai_translate: 16

+ 1 - 1
deploy/roles/mint-nginx/tasks/main.yml

@@ -28,7 +28,7 @@
 
 - name: Set dashboard alias
   become: true
-  ansible.builtin.shell: sed -i '25s#.*#alias {{ app_deploy_target }}/dashboard-v4/dashboard/dist/#' /etc/nginx/sites-enabled/{{ app_domain }}.conf
+  ansible.builtin.shell: sed -i '25s#.*#alias {{ app_deploy_target }}/dashboard-v4/dashboard/dist/;#' /etc/nginx/sites-enabled/{{ app_domain }}.conf
 
 - name: Reload nginx.conf
   become: true

+ 1 - 1
deploy/roles/mint-nginx/templates/fpm.conf.j2

@@ -2,7 +2,7 @@ upstream php_fpm_{{ app_php_fpm_port }} {
    # least_conn;
    
    {% for host in groups['php_fpm'] %}
-      server {{ host }}:{{ app_php_fpm_port }} weight=10;
+   server {{ host }}:{{ app_php_fpm_port }} weight=10;
    {% endfor %}
 
    # server 127.0.0.1:{{ app_php_fpm_port }} backup;

+ 6 - 0
deploy/roles/mint-v2.2/tasks/main.yml

@@ -35,6 +35,12 @@
     dest: "{{ app_deploy_target }}/scripts/run.sh"
     mode: "0555"
 
+- name: Upload php-fpm.sh
+  become: true
+  ansible.builtin.template:
+    src: containers/php-fpm.sh.j2
+    dest: "/srv/php-fpm-{{ app_php_version }}.sh"
+    mode: "0555"
 # -----------------------------------------------------------------------------
 
 - name: Setup laravel

+ 5 - 0
deploy/roles/mint-v2.2/templates/containers/php-fpm.sh.j2

@@ -0,0 +1,5 @@
+#!/bin/sh
+
+docker run --rm --hostname=mint -p {{ app_php_fpm_port }}:9000 -v /srv:/srv:z {{ app_docker_image_name }} /bin/bash -c \
+    "sed -i 's/^listen = .*/listen = 9000/g' /etc/php/{{ app_php_version }}/fpm/pool.d/www.conf && /usr/sbin/php-fpm{{ app_php_version }} --nodaemonize --fpm-config /etc/php/{{ app_php_version }}/fpm/php-fpm.conf"
+   

+ 1 - 4
deploy/roles/mint-v2.2/templates/containers/run.sh.j2

@@ -21,10 +21,7 @@ elif [ "$1" = "ai-translate" ]; then
 elif [ "$1" = "openai-proxy" ]; then
     cd $WORK_DIR/openai-proxy/
     source "$HOME/.nvm/nvm.sh"    
-    node dist/main.*.js config.json
-elif [ "$1" = "php-fpm" ]; then
-    sed -i 's/^listen = .*/listen = 9000/g' /etc/php/{{ app_php_version }}/fpm/pool.d/www.conf
-    /usr/sbin/php-fpm{{ app_php_version }} --nodaemonize --fpm-config /etc/php/{{ app_php_version }}/fpm/php-fpm.conf
+    node dist/main.*.js config.json    
 elif [ "$1" = "setup" ]; then
     cd $WORK_DIR/api-v8/
     echo "caching configuration "