Skip to content

Commit c644fea

Browse files
committed
Fixed webapp deploy
1 parent 7a70575 commit c644fea

File tree

2 files changed

+18
-44
lines changed

2 files changed

+18
-44
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ docs/inv-chatgpt.ini
6262
docs/monthly cost.png
6363
ansible/ansible command.txt
6464
infra/.terraform.lock.hcl
65-
*node_modules/*
6665
docs/query.txt
6766
infra/import-resources.bat
6867
docs/tests.txt

ansible/deploy-frontend.yml

Lines changed: 18 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,34 @@
11
---
2-
- name: Deploy EJS Frontend to Azure Web App (Node.js)
2+
- name: Deploy frontend to Azure Web App
33
hosts: localhost
4-
connection: local
54
gather_facts: no
65
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
1210

1311
tasks:
14-
- name: Disable Oryx build to prevent deployment timeout
12+
- name: Enable Oryx build (SCM_DO_BUILD_DURING_DEPLOYMENT=true)
1513
shell: |
1614
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
2018
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)
4620
shell: |
47-
zip -r {{ ZIP_PATH }} . -x "node_modules/*"
21+
zip -r {{ zip_path }} . -x "node_modules/*" -x ".next/*" -x "dist/*"
4822
args:
49-
chdir: "{{ FRONTEND_PATH }}"
23+
chdir: "{{ frontend_path }}"
5024

51-
- name: Deploy zip to Azure Web App using config-zip
25+
- name: Deploy zip to Azure Web App
5226
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
5732
5833
- name: Show success message
5934
debug:

0 commit comments

Comments
 (0)