Skip to content

Commit bc152a6

Browse files
authored
Merge pull request #18 from onaio/opensrp-web-deployment-tweaks
Opensrp web deployment tweaks
2 parents 0b68d4c + 4e2c0c4 commit bc152a6

File tree

13 files changed

+118
-25
lines changed

13 files changed

+118
-25
lines changed

.github/workflows/main.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ jobs:
2424
- name: Install dependencies
2525
run: |
2626
docker --version
27-
sudo apt install python-docker
2827
python -m pip install --upgrade pip
2928
pip install -r requirements.txt
3029
- name: Test with molecule
3130
run: |
32-
molecule test
31+
molecule test --all

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
*.log
33
yarn.lock
44
.vagrant/
5-
*.pyc
5+
*.pyc
6+
venv/
7+
.cache/

.yamllint

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
extends: default
33

4+
ignore:
5+
venv/
6+
47
rules:
58
braces:
69
max-spaces-inside: 1

defaults/main.yml

+14
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ react_app_path: "{{ react_checkout_path }}"
3636
react_log_path: "/var/log/{{ react_app_name }}"
3737
react_max_versioned_folders: 10
3838

39+
# shows the full structure of the react_build_cmds variable
40+
# react_build_cmds:
41+
# - cmd: build # yarn command to run
42+
# args: --production # optional arguments to pass
43+
# path: /var/www/myapp # optional chdir path
44+
# ignore_errors: yes # optional don't fail on yarn errors
45+
# env: # optional environment settings
46+
# NODE_ENV: production
47+
react_build_cmds:
48+
- cmd: build
49+
path: "{{react_app_path}}"
50+
react_build_cmds_default_env: {}
51+
react_build_default_cmd: build
52+
3953
# app settings
4054
react_app_settings:
4155
REACT_APP_WEBSITE_NAME: 'React Example App'

meta/main.yml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
galaxy_info:
3+
role_name: react
4+
namespace: "ona"
35
author: Ona Engineering
46
company: Ona Systems Inc
57
description: Install and configure React

molecule/default/molecule.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ dependency:
44
driver:
55
name: docker
66
platforms:
7-
- name: ubuntu-18.04
7+
- name: ubuntu-1804-default
88
image: solita/ubuntu-systemd:18.04
99
privileged: true
1010
command: /sbin/init
1111
provisioner:
1212
log: true
1313
name: ansible
14-
playbook:
15-
prepare: prepare.yml
14+
playbooks:
15+
prepare: ../resources/playbooks/prepare.yml
16+
converge: ../resources/playbooks/converge.yml
1617
options:
17-
verbose: true
18+
vvv: true
1819
verifier:
1920
name: testinfra
21+
directory: ../resources/tests/
2022
scenario:
2123
test_sequence:
2224
- dependency
@@ -34,4 +36,4 @@ scenario:
3436
lint: |
3537
set -e
3638
yamllint .
37-
flake8
39+
ansible-lint .
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
- name: Converge
3+
hosts: all
4+
roles:
5+
- role: ansible-react
6+
vars:
7+
react_system_user: "react"
8+
react_system_group: "www-data"
9+
react_system_user_home: "/home/{{ react_system_user }}"
10+
react_node_version: 10.x
11+
react_git_url: "https://github.com/onaio/reveal-frontend.git"
12+
react_git_version: "v1.0.0"
13+
react_app_settings:
14+
GENERATE_SOURCEMAP: "false"
15+
SKIP_PREFLIGHT_CHECK: "true"
16+
react_remote_js_build: true
17+
react_app_path: "{{ react_checkout_path }}"
File renamed without changes.

molecule/default/converge.yml molecule/ubuntu-1804-opensrp/converge.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,10 @@
1414
GENERATE_SOURCEMAP: "false"
1515
SKIP_PREFLIGHT_CHECK: "true"
1616
react_remote_js_build: false
17-
react_local_app_path: "{{ react_local_checkout_path }}/client"
18-
react_app_path: "{{ react_checkout_path }}/client"
17+
react_local_app_path: "{{ react_local_checkout_path }}/app"
18+
react_app_path: "{{ react_checkout_path }}/app"
19+
react_build_cmds:
20+
- cmd: lerna:prepublish
21+
args: --scope @opensrp/store
22+
- cmd: lerna:prepublish
23+
- cmd: build
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
dependency:
3+
name: galaxy
4+
driver:
5+
name: docker
6+
platforms:
7+
- name: ubuntu-1804-opensrp
8+
image: solita/ubuntu-systemd:18.04
9+
privileged: true
10+
command: /sbin/init
11+
provisioner:
12+
log: true
13+
name: ansible
14+
playbooks:
15+
prepare: ../resources/playbooks/prepare.yml
16+
converge: converge.yml
17+
options:
18+
vvv: false
19+
verifier:
20+
name: testinfra
21+
directory: ../resources/tests/
22+
scenario:
23+
test_sequence:
24+
- dependency
25+
- lint
26+
- cleanup
27+
- destroy
28+
- syntax
29+
- create
30+
- prepare
31+
- converge
32+
- side_effect
33+
- verify
34+
- cleanup
35+
- destroy
36+
lint: |
37+
set -e
38+
yamllint .
39+
ansible-lint .

requirements.txt

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
molecule[docker]==3.1.4
2-
flake8==3.7.9
1+
molecule[docker]==3.2.3
32
yamllint==1.25.0
4-
testinfra==4.1.0
3+
testinfra==4.1.0
4+
ansible==3.1.0
5+
ansible-base==2.10.6
6+
ansible-lint==5.0.3

tasks/configure.yml

+20-12
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@
1818
become: true
1919
become_user: "{{ react_local_user }}"
2020

21-
- name: Compile Javascript locally
22-
command: yarn build
23-
args:
24-
chdir: "{{ react_local_checkout_path }}"
25-
delegate_to: localhost
26-
become: true
21+
- name: Build app locally
2722
become_user: "{{ react_local_user }}"
23+
become: true
24+
delegate_to: localhost
25+
environment: "{{ item.env | default(react_build_cmds_default_env) }}"
26+
command: "yarn {{ item.cmd | default(react_build_default_cmd) }} {{ item.args | default() }}"
27+
register: yarn_build_result
28+
args:
29+
chdir: "{{ item.path | default(react_local_checkout_path) }}"
30+
failed_when: "yarn_build_result.stderr is defined and yarn_build_result.stderr.find('error ') != -1"
31+
with_items: "{{ react_build_cmds }}"
2832

2933
- name: Remove node_modules before compression
3034
block:
@@ -39,7 +43,7 @@
3943

4044
- name: remove node_modules manually
4145
file:
42-
path: "{{ react_checkout_path }}/node_modules"
46+
path: "{{ react_local_checkout_path }}/node_modules"
4347
state: absent
4448
delegate_to: localhost
4549
become: true
@@ -76,12 +80,16 @@
7680
become: true
7781
become_user: "{{ react_system_user }}"
7882

79-
- name: Compile Javascript
80-
command: yarn build
81-
args:
82-
chdir: "{{ react_checkout_path }}"
83-
become: true
83+
- name: Build app locally
8484
become_user: "{{ react_system_user }}"
85+
become: true
86+
environment: "{{ item.env | default(react_build_cmds_default_env) }}"
87+
command: "yarn {{ item.cmd | default(react_build_default_cmd) }} {{ item.args | default() }}"
88+
register: yarn_build_result
89+
args:
90+
chdir: "{{ item.path | default(react_checkout_path) }}"
91+
failed_when: "yarn_build_result.stderr is defined and yarn_build_result.stderr.find('error ') != -1"
92+
with_items: "{{ react_build_cmds }}"
8593

8694
when: "react_remote_js_build|bool"
8795

0 commit comments

Comments
 (0)