-
Notifications
You must be signed in to change notification settings - Fork 3
Local build #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local build #14
Changes from all commits
c1224d6
fe7744a
aee7ef2
f261f3e
aaac8ce
c7d247c
08c6b2b
a60c568
7a5530f
ae4d8ed
d0b7bcf
f21e1c7
645b8b5
7cd4a12
1e403b7
4b0b16d
1c17c93
8d6ec2a
1431796
346f66d
f9cf5f5
05ea38c
0d9e238
74fdb2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,9 @@ | ||
| # Yarn | ||
| yarn_download_url: "https://yarnpkg.com/{{ yarn_version }}" | ||
| yarn_install_destination: "" | ||
|
|
||
| # user | ||
| react_system_user: "react" | ||
| react_system_group: "www-data" | ||
| react_system_user_home: "/home/{{ react_system_user }}" | ||
|
|
||
| # NVM | ||
| react_nvm_node_version: "{{ react_node_version }}" | ||
| react_nvm_nvm_root: "{{ react_system_user_home }}/.nvm" | ||
| react_nvm_node_dir: "{{ react_nvm_nvm_root }}/versions/node/{{ react_nvm_node_version }}" | ||
| react_nvm_npm_path: "{{ react_node_dir }}/bin/npm" | ||
| react_nvm_version: "v0.34.0" | ||
| react_local_user_home: "{{ lookup('env', 'HOME') }}" | ||
| react_local_user: "{{ lookup('env','USER') }}" | ||
|
|
||
| # git | ||
| react_git_url: | ||
|
|
@@ -22,18 +13,26 @@ react_git_key_filename: "id_ed25519" | |
| react_remove_git_key: true | ||
|
|
||
| # system-wide dependencies | ||
| react_system_wide_dependencies: | ||
| react_remote_system_wide_dependencies: | ||
| - yarn | ||
| - git | ||
| react_local_system_wide_dependencies: | ||
| - git | ||
| react_node_version: 10.x | ||
|
|
||
| # app | ||
| react_remote_js_build: True | ||
| react_local_checkout_path: "/tmp/{{ react_local_user }}/reveal" | ||
| react_env_name: "prod" | ||
| react_app_name: "{{ react_system_user }}" | ||
| react_codebase_path: "{{ react_system_user_home }}/app" | ||
| react_versioned_path: "{{ react_codebase_path }}-versioned" | ||
| react_checkout_path: "{{ react_versioned_path }}/{{ ansible_date_time['epoch'] }}" | ||
| react_log_path: "/var/log/{{ react_app_name }}" | ||
| react_max_versioned_folders: 10 | ||
|
|
||
| # app settings | ||
| react_app_settings: | ||
| REACT_APP_WEBSITE_NAME: 'React Example App' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason why this is being removed? |
||
| REACT_APP_WEBSITE_NAME: 'React Example App' | ||
| GENERATE_SOURCEMAP: "false" | ||
| SKIP_PREFLIGHT_CHECK: "true" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- | ||
| - name: Converge | ||
| hosts: all | ||
| roles: | ||
| - role: ansible-react | ||
| vars: | ||
| react_system_user: "react" | ||
| react_system_group: "www-data" | ||
| react_system_user_home: "/home/{{ react_system_user }}" | ||
| react_node_version: 10.x | ||
| react_git_url: "https://github.com/onaio/reveal-frontend" | ||
| react_git_version: "v0.6.2-rc1" | ||
| react_app_settings: | ||
| GENERATE_SOURCEMAP: "false" | ||
| SKIP_PREFLIGHT_CHECK: "true" | ||
| react_remote_js_build: False |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| - hosts: all | ||
| become: true | ||
| become_user: root | ||
| tasks: | ||
| - name: Install prerequisites | ||
| apt: | ||
| name: " {{ item }} " | ||
| update_cache: true | ||
| state: present | ||
| loop: | ||
| - curl | ||
| - gpg-agent |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,78 @@ | ||
| --- | ||
| - name: Copy environment variables file | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we remove this, will things still work for non-local builds? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah I suppose so. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just wondering because I dont want to break non local builds There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. non local builds should still run fine |
||
| template: | ||
| src: env.j2 | ||
| dest: "{{ react_checkout_path }}/.env" | ||
| mode: 0644 | ||
| owner: "{{ react_system_user }}" | ||
| group: "{{ react_system_group }}" | ||
| - name: configure build locally | ||
| block: | ||
| - name: Copy environment variables file locally | ||
| template: | ||
| src: env.j2 | ||
| dest: "{{ react_local_checkout_path }}/.env" | ||
| mode: 0644 | ||
| delegate_to: localhost | ||
peterMuriuki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| become: True | ||
| become_user: "{{ react_local_user }}" | ||
|
|
||
| - name: Install Javascript requirements locally | ||
| yarn: | ||
| path: "{{ react_local_checkout_path }}" | ||
| production: false | ||
| delegate_to: localhost | ||
| become: True | ||
| become_user: "{{ react_local_user }}" | ||
|
|
||
| - name: Compile Javascript locally | ||
| command: yarn build | ||
| args: | ||
| chdir: "{{ react_local_checkout_path }}" | ||
| delegate_to: localhost | ||
| become: True | ||
| become_user: "{{ react_local_user }}" | ||
|
|
||
| - name: Remove node_modules before compression | ||
| file: | ||
| path: "{{ react_local_checkout_path }}/node_modules" | ||
| state: absent | ||
| delegate_to: localhost | ||
| become: True | ||
| become_user: "{{ react_local_user }}" | ||
|
|
||
| - name: Compress Build folder locally | ||
| archive: | ||
| path: "{{ react_local_checkout_path }}/" | ||
| dest: "{{ react_local_checkout_path }}.tgz" | ||
| delegate_to: localhost | ||
| become: True | ||
| become_user: "{{ react_local_user }}" | ||
|
|
||
| - name: UnCompress Build folder to remote host | ||
| unarchive: | ||
| src: "{{ react_local_checkout_path }}.tgz" | ||
| dest: "{{ react_checkout_path }}" | ||
| become: True | ||
| become_user: "{{ react_system_user }}" | ||
| when: "not react_remote_js_build|bool" | ||
|
|
||
| - name: configure build remotely | ||
| block: | ||
| - name: Copy environment variables file | ||
| template: | ||
| src: env.j2 | ||
| dest: "{{ react_checkout_path }}/.env" | ||
| mode: 0644 | ||
|
|
||
| - name: Install Javascript requirements | ||
| yarn: | ||
| path: "{{ react_checkout_path }}" | ||
| production: false | ||
| become: True | ||
| become_user: "{{ react_system_user }}" | ||
|
|
||
| - name: Compile Javascript | ||
| command: yarn build | ||
| args: | ||
| chdir: "{{ react_checkout_path }}" | ||
| become: True | ||
| become_user: "{{ react_system_user }}" | ||
|
|
||
| - name: Install Javascript requirements | ||
| yarn: | ||
| path: "{{ react_checkout_path }}" | ||
| become: True | ||
| become_user: "{{ react_system_user }}" | ||
|
|
||
| - name: Compile Javascript | ||
| command: yarn build | ||
| args: | ||
| chdir: "{{ react_checkout_path }}" | ||
| become: True | ||
| become_user: "{{ react_system_user }}" | ||
| when: "react_remote_js_build|bool" | ||
|
|
||
| - name: Make the new codebase current | ||
| file: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you not require yarn to be installed locally when building locally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when building locally, node and yarn are a pre-requisite, that should be set up before hand.
I did not have any good idea on how to include tasks to set them up in this role(i.e. for local builds).
for admin host, I have installed yarn as a global npm package after having installed node using nvm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wording looks okay but I suppose it requires an actual test on my end to know for sure that there is absolutely a need to stick to the previous variable.