Browse Source

:bug: fix laravel setup

China Kassapa 2 months ago
parent
commit
afa2ab652d

+ 1 - 0
deploy/group_vars/all.yml

@@ -22,3 +22,4 @@ app_php81_image: "wikipali/mint:php-8.1-20251225"
 app_php84_image: "wikipali/mint:php-8.4-20260108"
 app_python_image: "wikipali/mint:php-8.4-20260108"
 app_nodejs_image: "wikipali/mint:php-8.4-20260108"
+app_pull_images: false

+ 1 - 1
deploy/roles/mint-build-v2.3/tasks/main.yml

@@ -19,7 +19,7 @@
 
 - name: Extract api-v8
   ansible.builtin.unarchive:
-    src: api-v8-{{ ansible_facts['architecture'] }}-20260116065749.tar.xz
+    src: api-v8-20260117.tar.xz
     dest: "{{ app_workspace }}/api-v8"
     creates: "{{ app_workspace }}/api-v8/composer.lock"
 

+ 18 - 0
deploy/roles/mint-v2.3/tasks/laravel-setup.yml

@@ -0,0 +1,18 @@
+- name: Create scripts folder
+  ansible.builtin.file:
+    path: "{{ app_deploy_target }}/scripts"
+    state: directory
+    mode: "0755"
+
+- name: Upload laravel.sh
+  ansible.builtin.template:
+    src: laravel.sh.j2
+    dest: "{{ app_deploy_target }}/scripts/laravel.sh"
+    mode: "0555"
+
+- name: Setup api-v8
+  ansible.builtin.command: docker run --rm -it -v /srv:/srv:z {{ app_php81_image }} {{ app_deploy_target }}/scripts/laravel.sh setup
+  
+- name: Setup api-v12
+  ansible.builtin.command: docker run --rm -it -v /srv:/srv:z {{ app_php84_image }} {{ app_deploy_target }}/scripts/laravel.sh setup
+  

+ 4 - 0
deploy/roles/mint-v2.3/tasks/main.yml

@@ -5,6 +5,7 @@
     - "{{ app_php84_image }}"
     - "{{ app_python_image }}"
     - "{{ app_nodejs_image }}"
+  when: app_pull_images
 
 - name: Create /srv/python3 folder
   become: true
@@ -43,5 +44,8 @@
 - name: Upload configurations
   ansible.builtin.import_tasks: config.yml
 
+- name: Setup laravel
+  ansible.builtin.import_tasks: laravel-setup.yml
+
 - name: Setup systemd services
   ansible.builtin.import_tasks: systemd.yml

+ 0 - 12
deploy/roles/mint-v2.3/tasks/systemd.yml

@@ -6,18 +6,6 @@
     owner: "{{ ansible_user }}"
     mode: "0755"
 
-- name: Create scripts folder
-  ansible.builtin.file:
-    path: "{{ app_deploy_target }}/scripts"
-    state: directory
-    mode: "0755"
-
-- name: Upload laravel.sh
-  ansible.builtin.template:
-    src: laravel.sh.j2
-    dest: "{{ app_deploy_target }}/scripts/laravel.sh"
-    mode: "0555"
-
 - name: Upload clean.py
   ansible.builtin.copy:
     src: clean.py

+ 6 - 4
deploy/roles/mint-v2.3/templates/laravel.sh.j2

@@ -13,14 +13,16 @@ if [[ "$ID" != "ubuntu" ]]; then
     echo "unsupported distribution $ID"
     exit 1
 fi
+
+. $HOME/.nvm/nvm.sh
 # -----------------------------------------------------------------------------
 
 export PHP_VERSION="$(php -r 'echo PHP_VERSION;')"
 
 if [[ "$PHP_VERSION" == "8.1.34" ]]; then
-    export WORKSPACE=$PWD/api-v8
-if [[ "$PHP_VERSION" == "8.4.16" ]]; then
-    export WORKSPACE=$PWD/api-v12
+    export WORKSPACE={{ app_deploy_target }}/api-v8
+elif [[ "$PHP_VERSION" == "8.4.16" ]]; then
+    export WORKSPACE={{ app_deploy_target }}/api-v12
 else
     echo "unsupported php $PHP_VERSION"
     exit 1
@@ -29,6 +31,7 @@ fi
 # -----------------------------------------------------------------------------
 
 if [[ "$#" -eq 1 && "$1" == "diagnose" ]]; then
+    echo "workspace: $WORKSPACE"
     php --version
     echo "NodeJs: $(node -v)"
     echo "npm: $(npm -v)"
@@ -45,7 +48,6 @@ elif [[ "$#" -eq 1 && "$1" == "setup" ]]; then
     php artisan view:cache
 
     echo "check file permissions"    
-    mkdir storage/logs
     chown -R www-data:www-data bootstrap/cache storage
 elif [[ "$#" -eq 1 ]]; then
     cd $WORKSPACE/

+ 1 - 1
deploy/roles/mint-v2.3/templates/php-fpm-8.1.service.j2

@@ -5,7 +5,7 @@ After=network-online.target
 
 [Service]
 Type=simple
-User=www-data
+User={{ ansible_user }}
 ExecStart=/usr/bin/docker run --rm --name php-fpm-8.1 -p 0.0.0.0:{{ app_php_fpm81_port }}:9000/tcp -v /srv:/srv:z {{ app_php81_image }} /srv/bin/php-fpm.sh 8.1
 ExecStop=/usr/bin/docker stop php-fpm-8.1
 WorkingDirectory=/srv

+ 1 - 1
deploy/roles/mint-v2.3/templates/php-fpm-8.4.service.j2

@@ -5,7 +5,7 @@ After=network-online.target
 
 [Service]
 Type=simple
-User=www-data
+User={{ ansible_user }}
 ExecStart=/usr/bin/docker run --rm --name php-fpm-8.4 -p 0.0.0.0:{{ app_php_fpm84_port }}:9000/tcp -v /srv:/srv:z {{ app_php84_image }} /srv/bin/php-fpm.sh 8.4
 ExecStop=/usr/bin/docker stop php-fpm-8.4
 WorkingDirectory=/srv

+ 1 - 1
docker/mint/Dockerfile

@@ -24,7 +24,7 @@ RUN apt -y install git vim locales locales-all inetutils-telnet iproute2 tzdata
     fonts-ipaexfont fonts-ipafont fonts-konatu fonts-ipafont-nonfree-jisx0208 fonts-ipafont-nonfree-uigothic \
     fonts-mikachan \
     fonts-tibetan-machine fonts-ddc-uchen fonts-monlam fonts-sambhota-tsugring fonts-sambhota-yigchung \
-    imagemagick ffmpeg graphviz pandoc texlive-full \
+    imagemagick ffmpeg graphviz pandoc texlive-full p7zip-full \
     python3-full python3-dev \
     libssl-dev libpq-dev libmysqlclient-dev \
     && apt -y autoremove \