Skip to content

Commit

Permalink
✨ Add FormIO (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
anarion80 authored May 9, 2024
1 parent ccaf61c commit 45cfe53
Show file tree
Hide file tree
Showing 11 changed files with 228 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ If you have a spare domain name you can configure applications to be accessible
* [Flame](https://github.com/pawelmalak/flame/) - Flarum is a delightfully simple discussion platform for your website
* [Flarum](https://flarum.org/) - Self-hosted startpage for your server
* [Flatnotes](https://flatnotes.io/) - Self-hosted, database-less note taking web app
* [FormIO](https://github.com/formio/formio) - SA Form and Data Management Platform for Progressive Web Applications
* [Fresh RSS](https://freshrss.org/) - Self-hosted RSS feed aggregator like Leed or Kriss Feed
* [Frigate](https://frigate.video/) - Frigate is an open source NVR built around real-time AI object detection
* [Gaps](https://github.com/JasonHHouse/gaps) - Find the missing movies in your Plex Server
Expand Down
4 changes: 4 additions & 0 deletions nas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@
tags:
- flatnotes

- role: formio
tags:
- formio

- role: freshrss
tags:
- freshrss
Expand Down
56 changes: 56 additions & 0 deletions roles/formio/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
formio_enabled: false
formio_available_externally: false

# directories
formio_data_directory: "{{ docker_home }}/formio"

# network
formio_port: "3019"
formio_hostname: "formio"
formio_network_name: "formio"

# specs
formio_memory: 1g
formio_db_memory: 1g

# docker
formio_container_name: formio
formio_image_name: "garfieldwtf/formio"
formio_image_version: latest
formio_db_container_name: formio-mongodb
formio_db_image_name: mongo
formio_db_image_version: latest
formio_user_id: "1000"
formio_group_id: "1000"

# formio
formio_mongo_initdb_root_username: "formio"
formio_mongo_initdb_root_password: "formio"
formio_email_type: "smtp"
formio_email_host: "smtp.gmail.com"
formio_email_port: "587"
formio_email_secure: "false"
formio_email_ignore_tls: "false"
formio_email_auth_user: ""
formio_email_auth_password: ""
formio_email_allow_unauthorized_certs: "true"
formio_debug: "formio:*"
formio_node_config:
mongo: "mongodb://{{ formio_mongo_initdb_root_username }}:{{ formio_mongo_initdb_root_password }}@{{ formio_db_container_name }}:27017"
domain: "https://{{ formio_hostname }}.{{ ansible_nas_domain }}"
email:
type: "{{ formio_email_type }}"
settings:
email:
smtp:
host: "{{ formio_email_host }}"
port: "{{ formio_email_port }}"
secure: "{{ formio_email_secure }}"
ignoreTLS: "{{ formio_email_ignore_tls }}"
auth:
user: "{{ formio_email_auth_user }}"
pass: "{{ formio_email_auth_password }}"
allowUnauthorizedCerts: "{{ formio_email_allow_unauthorized_certs }}"
formio_root_email: "formio@{{ ansible_nas_domain }}"
formio_root_password: "{{ formio_mongo_initdb_root_password }}"
11 changes: 11 additions & 0 deletions roles/formio/docs/formio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# FormIO

Homepage: [https://github.com/formio/formio](https://github.com/formio/formio)

A Form and Data Management Platform for Progressive Web Applications.

## Usage

Set `formio_enabled: true` in your `inventories/<your_inventory>/group_vars/nas.yml` file.

formio web interface can be found at [http://ansible_nas_host_or_ip:3019](http://ansible_nas_host_or_ip:3019).
6 changes: 6 additions & 0 deletions roles/formio/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
formio_enabled: true
10 changes: 10 additions & 0 deletions roles/formio/molecule/default/side_effect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Stop
hosts: all
become: true
tasks:
- name: "Include {{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }} role"
ansible.builtin.include_role:
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
vars:
formio_enabled: false
26 changes: 26 additions & 0 deletions roles/formio/molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Include vars
ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Get formio db container state
community.docker.docker_container:
name: "{{ formio_db_container_name }}"
register: result_db

- name: Get formio container state
community.docker.docker_container:
name: "{{ formio_container_name }}"
register: result

- name: Check if formio containers are running
ansible.builtin.assert:
that:
- result_db.container['State']['Status'] == "running"
- result_db.container['State']['Restarting'] == false
- result.container['State']['Status'] == "running"
- result.container['State']['Restarting'] == false
26 changes: 26 additions & 0 deletions roles/formio/molecule/default/verify_stopped.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Include vars
ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Try and stop and remove formio db
community.docker.docker_container:
name: "{{ formio_db_container_name }}"
state: absent
register: result_db

- name: Try and stop and remove formio
community.docker.docker_container:
name: "{{ formio_container_name }}"
state: absent
register: result

- name: Check if formio is stopped
ansible.builtin.assert:
that:
- not result_db.changed
- not result.changed
1 change: 1 addition & 0 deletions roles/formio/requirements.yml
73 changes: 73 additions & 0 deletions roles/formio/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
- name: Start FormIO
block:
- name: Create FormIO Directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
with_items:
- "{{ formio_data_directory }}"

- name: Create FormIO network
community.docker.docker_network:
name: "{{ formio_network_name }}"

- name: Create FormIO Db Docker Container
community.docker.docker_container:
name: "{{ formio_db_container_name }}"
image: "{{ formio_db_image_name }}:{{ formio_db_image_version }}"
pull: true
volumes:
- "{{ formio_data_directory }}/data/mdb-data:/data/db:rw"
networks:
- name: "{{ formio_network_name }}"
network_mode: "{{ formio_network_name }}"
container_default_behavior: no_defaults
env:
MONGO_INITDB_ROOT_USERNAME: "{{ formio_mongo_initdb_root_username }}"
MONGO_INITDB_ROOT_PASSWORD: "{{ formio_mongo_initdb_root_password }}"
labels:
traefik.enable: "false"
restart_policy: always
memory: "{{ formio_db_memory }}"

- name: Create FormIO Docker Container
community.docker.docker_container:
container_default_behavior: no_defaults
name: "{{ formio_container_name }}"
image: "{{ formio_image_name }}:{{ formio_image_version }}"
pull: true
networks:
- name: "{{ formio_network_name }}"
network_mode: "{{ formio_network_name }}"
ports:
- "{{ formio_port }}:3001"
command: npm run start:prod
env:
DEBUG: "{{ formio_debug }}"
NODE_CONFIG: "{{ formio_node_config | to_json }}"
ROOT_EMAIL: "{{ formio_root_email }}"
ROOT_PASSWORD: "{{ formio_root_password }}"
restart_policy: unless-stopped
memory: "{{ formio_memory }}"
labels:
traefik.enable: "{{ formio_available_externally | string }}"
traefik.http.routers.formio.rule: "Host(`{{ formio_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.formio.tls.certresolver: "letsencrypt"
traefik.http.routers.formio.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.formio.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.formio.loadbalancer.server.port: "3001"
when: formio_enabled is true

- name: Stop FormIO
block:
- name: Stop FormIO db
community.docker.docker_container:
name: "{{ formio_db_container_name }}"
state: absent

- name: Stop FormIO
community.docker.docker_container:
name: "{{ formio_container_name }}"
state: absent
when: formio_enabled is false
14 changes: 14 additions & 0 deletions website/docs/applications/other/formio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: "FormIO"
description: "A Form and Data Management Platform for Progressive Web Applications."
---

Homepage: [https://github.com/formio/formio](https://github.com/formio/formio)

A Form and Data Management Platform for Progressive Web Applications.

## Usage

Set `formio_enabled: true` in your `inventories/<your_inventory>/group_vars/nas.yml` file.

formio web interface can be found at [http://ansible_nas_host_or_ip:3019](http://ansible_nas_host_or_ip:3019).

0 comments on commit 45cfe53

Please sign in to comment.