|
1 | 1 | --- |
2 | | -- name: Deploy EJS Frontend to Azure Web App (Node.js) |
| 2 | +- name: Deploy frontend to Azure Web App |
3 | 3 | hosts: localhost |
4 | | - connection: local |
5 | 4 | gather_facts: no |
6 | 5 | vars: |
7 | | - APP_SERVICE_NAME: "{{ lookup('env', 'APP_SERVICE_NAME') }}" |
8 | | - RESOURCE_GROUP_NAME: "{{ lookup('env', 'RESOURCE_GROUP_NAME') }}" |
9 | | - FRONTEND_PATH: "../src/movie-analyst-ui" |
10 | | - ZIP_PATH: "/tmp/frontend.zip" |
11 | | - BACKEND_URL: "{{ lookup('env', 'LB_API_URL') }}" |
| 6 | + resource_group: softdevrg |
| 7 | + app_name: softdefault-movies-app |
| 8 | + frontend_path: /home/adminuser/frontend # Ajusta esta ruta si es diferente |
| 9 | + zip_path: /tmp/frontend.zip |
12 | 10 |
|
13 | 11 | tasks: |
14 | | - - name: Disable Oryx build to prevent deployment timeout |
| 12 | + - name: Enable Oryx build (SCM_DO_BUILD_DURING_DEPLOYMENT=true) |
15 | 13 | shell: | |
16 | 14 | az webapp config appsettings set \ |
17 | | - --resource-group {{ RESOURCE_GROUP_NAME }} \ |
18 | | - --name {{ APP_SERVICE_NAME }} \ |
19 | | - --settings SCM_DO_BUILD_DURING_DEPLOYMENT=false |
| 15 | + --resource-group {{ resource_group }} \ |
| 16 | + --name {{ app_name }} \ |
| 17 | + --settings SCM_DO_BUILD_DURING_DEPLOYMENT=true |
20 | 18 |
|
21 | | - - name: Set BACKEND_URL in .env file |
22 | | - copy: |
23 | | - dest: "{{ FRONTEND_PATH }}/.env" |
24 | | - content: | |
25 | | - BACKEND_URL={{ BACKEND_URL }} |
26 | | -
|
27 | | - - name: Install Node.js dependencies using npm ci |
28 | | - shell: npm ci |
29 | | - args: |
30 | | - chdir: "{{ FRONTEND_PATH }}" |
31 | | - |
32 | | - - name: Set startup file command (npm start) |
33 | | - shell: | |
34 | | - az webapp config set \ |
35 | | - --resource-group {{ RESOURCE_GROUP_NAME }} \ |
36 | | - --name {{ APP_SERVICE_NAME }} \ |
37 | | - --startup-file "npm start" |
38 | | -
|
39 | | - - name: Ensure zip is installed |
40 | | - package: |
41 | | - name: zip |
42 | | - state: present |
43 | | - become: yes |
44 | | - |
45 | | - - name: Create zip package for deployment (excluding node_modules) |
| 19 | + - name: Create zip package (exclude node_modules and build artifacts) |
46 | 20 | shell: | |
47 | | - zip -r {{ ZIP_PATH }} . -x "node_modules/*" |
| 21 | + zip -r {{ zip_path }} . -x "node_modules/*" -x ".next/*" -x "dist/*" |
48 | 22 | args: |
49 | | - chdir: "{{ FRONTEND_PATH }}" |
| 23 | + chdir: "{{ frontend_path }}" |
50 | 24 |
|
51 | | - - name: Deploy zip to Azure Web App using config-zip |
| 25 | + - name: Deploy zip to Azure Web App |
52 | 26 | shell: | |
53 | | - az webapp deployment source config-zip \ |
54 | | - --resource-group {{ RESOURCE_GROUP_NAME }} \ |
55 | | - --name {{ APP_SERVICE_NAME }} \ |
56 | | - --src {{ ZIP_PATH }} |
| 27 | + az webapp deploy \ |
| 28 | + --resource-group {{ resource_group }} \ |
| 29 | + --name {{ app_name }} \ |
| 30 | + --src-path {{ zip_path }} \ |
| 31 | + --type zip |
57 | 32 |
|
58 | 33 | - name: Show success message |
59 | 34 | debug: |
|
0 commit comments