From c0177e712cab9c0537b87aae8897845c1ba92bf0 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 10 Feb 2021 19:00:07 +0100 Subject: [PATCH] Update to 2021-02-10 19:00 --- roles/appsmith/defaults/main.yml | 3 +++ roles/appsmith/meta/main.yml | 1 + roles/appsmith/tasks/.install.yml.swp | Bin 0 -> 16384 bytes roles/appsmith/tasks/cleanup.yml | 2 ++ roles/appsmith/tasks/conf.yml | 5 +++++ roles/appsmith/tasks/install.yml | 29 ++++++++++++++++++++++++++++ roles/appsmith/templates/nginx.conf.j2 | 34 +++++++++++++++++++++++++++++++++ 7 files changed, 74 insertions(+) create mode 100644 roles/appsmith/tasks/.install.yml.swp create mode 100644 roles/appsmith/templates/nginx.conf.j2 diff --git a/roles/appsmith/defaults/main.yml b/roles/appsmith/defaults/main.yml index 3480328..69681e1 100644 --- a/roles/appsmith/defaults/main.yml +++ b/roles/appsmith/defaults/main.yml @@ -35,3 +35,6 @@ appsmith_email_tls: "{{ (appsmith_email_port == 587) | ternary(True,False) }}" # Encryption settings. If not defined, random values will be created and used # appsmith_encryption_pass: p@ssw0rd # appsmith_encryption_salt: Salt + +# Public URL used to access appsmith +appsmith_public_url: http://{{ inventory_hostname }} diff --git a/roles/appsmith/meta/main.yml b/roles/appsmith/meta/main.yml index f387b2f..cb8d365 100644 --- a/roles/appsmith/meta/main.yml +++ b/roles/appsmith/meta/main.yml @@ -8,3 +8,4 @@ dependencies: when: appsmith_redis_url | urlsplit('hostname') in ['localhost','127.0.0.1'] - role: mongodb_server when: appsmith_mongo_url | urlsplit('hostname') in ['localhost','127.0.0.1'] + - role: nginx diff --git a/roles/appsmith/tasks/.install.yml.swp b/roles/appsmith/tasks/.install.yml.swp new file mode 100644 index 0000000000000000000000000000000000000000..65217a7baade8f1afd0ed24c9c5fd152e261d313 GIT binary patch literal 16384 zcmeI2ON<;x8OJ+zLJ}t?C`P$(;Ik8H!KAx)HmigTGI5eMVXciFtsMlBrAbY9?M&}< z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u!~azkAMg$YjQNP){4`fSuWjnFmDXwr!71#nwv;6J~DPux5(hhE1$CSdIZ+FpXY_ z>9x!F99AFbfu~nbQKv&pVY;!##<^~1kg#S~3*BS7Fx4XQPBLU-z|&sS4R#hWo0v%L zENa|Tzn$h+B?hgF7z5ExJDs+XIBS=%Qi8SolJOeG=7}L|mz9Joq(X{;O#2~@(T7^f zyqQ0nkl9R3{JKY=i`s=jt!6;91rO9p=H^k;)66go1GE0$#CrQRVAlWc`~IJ?j{i1z z5nKTbJOUyRf_uQ5SigS@d<{GgI5-S$0dFC_H*C7Enza4p74Qmp1-t@Y0k42pz$@St z@CtYZyaNA81@>48oAqLeuX4$x6ZH~)G4WspiW`95C zI*FUdW~0aM{YPoLONe!B%1=BrKfh}kie22;m_W_zG?Y?~>hB)AR>U)VQe%Pdb`iGD zvEEnMK2r5w0Mokq#GGBf&)q-AFOIQwAm{Ek9~3@`Xt~*k#}B?oVN>F>G>;;yEqp#G z@SQGY*jpC8ikqFW<{N}tysy^JT+}_czTSH~e~+z)x)`v*RDj#Zv-|&%*(A=A{Zz_y aRoL>x&F@5&wDK?UGMCu2ZwgMvh~Qrs+RR@7 literal 0 HcmV?d00001 diff --git a/roles/appsmith/tasks/cleanup.yml b/roles/appsmith/tasks/cleanup.yml index a3cfcbf..7524f1b 100644 --- a/roles/appsmith/tasks/cleanup.yml +++ b/roles/appsmith/tasks/cleanup.yml @@ -4,4 +4,6 @@ file: path={{ item }} state=absent loop: - "{{ appsmith_root_dir }}/archives/{{ appsmith_current_version }}" + - "{{ appsmith_root_dir }}/tmp/appsmith-{{ appsmith_version }}" + - "{{ appsmith_root_dir }}/tmp/appsmith-{{ appsmith_version }}.tar.gz" tags: appsmith diff --git a/roles/appsmith/tasks/conf.yml b/roles/appsmith/tasks/conf.yml index 610be72..ffe7ab5 100644 --- a/roles/appsmith/tasks/conf.yml +++ b/roles/appsmith/tasks/conf.yml @@ -6,3 +6,8 @@ - env notify: restart appsmith-server tags: appsmith + +- name: Deploy nginx conf + template: src=nginx.conf.j2 dest=/etc/nginx/ansible_conf.d/appsmith.conf + notify: reload nginx + tags: appsmith diff --git a/roles/appsmith/tasks/install.yml b/roles/appsmith/tasks/install.yml index 67eb7f1..428efac 100644 --- a/roles/appsmith/tasks/install.yml +++ b/roles/appsmith/tasks/install.yml @@ -79,6 +79,35 @@ copy: src={{ item }} dest={{ appsmith_root_dir }}/server/plugins/ remote_src=True loop: "{{ appsmith_plugins_jar.stdout_lines }}" + - name: Install yarn + npm: + name: yarn + path: "{{ appsmith_root_dir }}/src/app/client" + + - name: Install NodeJS dependencies + command: ./node_modules/yarn/bin/yarn install --ignore-engines + args: + chdir: "{{ appsmith_root_dir }}/src/app/client" + + # Not sure why but yarn installs webpack 4.46.0 while appsmith wants 4.44.2 + - name: Install correct webpack version + command: ./node_modules/yarn/bin/yarn add webpack@4.44.2 --ignore-engines + args: + chdir: "{{ appsmith_root_dir }}/src/app/client" + + - name: Build the client + command: ./node_modules/.bin/craco --max-old-space-size=4096 build --config craco.build.config.js + args: + chdir: "{{ appsmith_root_dir }}/src/app/client" + + - name: Move the client to its final dir + synchronize: + src: "{{ appsmith_root_dir }}/src/app/client/build/" + dest: "{{ appsmith_root_dir }}/client/" + compress: False + delete: True + delegate_to: "{{ inventory_hostname }}" + tags: appsmith - name: Deploy systemd unit diff --git a/roles/appsmith/templates/nginx.conf.j2 b/roles/appsmith/templates/nginx.conf.j2 new file mode 100644 index 0000000..627b447 --- /dev/null +++ b/roles/appsmith/templates/nginx.conf.j2 @@ -0,0 +1,34 @@ +server { + listen 80; + server_name {{ appsmith_public_url | urlsplit('hostname') }}; + include /etc/nginx/ansible_conf.d/acme.inc; + root {{ appsmith_root_dir }}/client; + client_max_body_size 10M; + + if ($request_method !~ ^(GET|POST|HEAD|PUT|DELETE|PATCH)$ ) { + return 405; + } + + # Send info about the original request to the backend + proxy_set_header X-Forwarded-For "$proxy_add_x_forwarded_for"; + proxy_set_header X-Real-IP "$remote_addr"; + proxy_set_header X-Forwarded-Proto "$scheme"; + proxy_set_header X-Forwarded-Host "$host"; + proxy_set_header Host "$host"; + + location / { + try_files $uri /index.html =404; + } + location /f { + proxy_pass https://cdn.optimizely.com/; + } + location /api { + proxy_pass http://127.0.0.1:{{ appsmith_server_port }}; + } + location /oauth2 { + proxy_pass http://127.0.0.1:{{ appsmith_server_port }}; + } + location /login { + proxy_pass http://127.0.0.1:{{ appsmith_server_port }}; + } +}