Skip to content

Commit 8b59fc6

Browse files
committed
Redeploy site
1 parent 1fb3290 commit 8b59fc6

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

ansible/deploy-frontend.yml

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
2-
- name: Deploy frontend to Azure Web App
2+
- name: Deploy EJS Frontend to Azure Web App (Node.js)
33
hosts: localhost
44
connection: local
5+
gather_facts: no
56
vars:
67
APP_SERVICE_NAME: "{{ lookup('env', 'APP_SERVICE_NAME') }}"
78
RESOURCE_GROUP_NAME: "{{ lookup('env', 'RESOURCE_GROUP_NAME') }}"
@@ -10,36 +11,42 @@
1011
BACKEND_URL: "{{ lookup('env', 'LB_API_URL') }}"
1112

1213
tasks:
14+
- name: Enable Oryx build
15+
shell: |
16+
az webapp config appsettings set \
17+
--resource-group {{ RESOURCE_GROUP_NAME }} \
18+
--name {{ APP_SERVICE_NAME }} \
19+
--settings SCM_DO_BUILD_DURING_DEPLOYMENT=true
1320
14-
- name: Ensure frontend path exists
15-
stat:
16-
path: "{{ FRONTEND_PATH }}"
17-
register: frontend_dir
18-
19-
- name: Fail if frontend path does not exist
20-
fail:
21-
msg: "The frontend path '{{ FRONTEND_PATH }}' does not exist."
22-
when: not frontend_dir.stat.exists
21+
- name: Set BACKEND_URL in .env file
22+
copy:
23+
dest: "{{ FRONTEND_PATH }}/.env"
24+
content: |
25+
BACKEND_URL={{ BACKEND_URL }}
2326
24-
- name: Create zip package (exclude node_modules and build artifacts)
25-
command: >
26-
zip -r {{ ZIP_PATH }} . -x "node_modules/*" -x ".next/*" -x "dist/*"
27+
- name: Install Node.js dependencies using npm ci
28+
shell: npm ci
2729
args:
2830
chdir: "{{ FRONTEND_PATH }}"
2931

30-
- name: Enable Oryx build (SCM_DO_BUILD_DURING_DEPLOYMENT=true)
32+
- name: Set startup file command (npm start)
3133
shell: |
32-
az webapp config appsettings set \
34+
az webapp config set \
3335
--resource-group {{ RESOURCE_GROUP_NAME }} \
3436
--name {{ APP_SERVICE_NAME }} \
35-
--settings SCM_DO_BUILD_DURING_DEPLOYMENT=true
37+
--startup-file "npm start"
38+
39+
- name: Ensure zip is installed
40+
package:
41+
name: zip
42+
state: present
43+
become: yes
3644

37-
- name: Set backend API URL as environment variable
45+
- name: Create zip package for deployment (excluding node_modules)
3846
shell: |
39-
az webapp config appsettings set \
40-
--resource-group {{ RESOURCE_GROUP_NAME }} \
41-
--name {{ APP_SERVICE_NAME }} \
42-
--settings NEXT_PUBLIC_BACKEND_URL={{ BACKEND_URL }}
47+
zip -r {{ ZIP_PATH }} . -x "node_modules/*"
48+
args:
49+
chdir: "{{ FRONTEND_PATH }}"
4350

4451
- name: Deploy zip to Azure Web App
4552
shell: |

0 commit comments

Comments
 (0)