Skip to content

Commit

Permalink
✨ Add evershop
Browse files Browse the repository at this point in the history
  • Loading branch information
anarion80 committed May 22, 2024
1 parent 45ddc1f commit d6b6d05
Show file tree
Hide file tree
Showing 11 changed files with 237 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ If you have a spare domain name you can configure applications to be accessible
* [Emby](https://emby.media/) - Media streaming and management
* [ebusd](https://github.com/john30/ebusd) - daemon for communication with eBUS heating systems
* [ESPHome](https://esphome.io/) - ESP8266/ESP32 programming and management for home automation
* [Evershop](https://github.com/evershopcommerce/evershop) - NodeJS E-commerce Platform
* [Excalidraw](https://excalidraw.com/) - Virtual whiteboard for sketching hand-drawn like diagrams
* [Firefly III](https://firefly-iii.org/) - Free and open source personal finance manager
* [Flame](https://github.com/pawelmalak/flame/) - Flarum is a delightfully simple discussion platform for your website
Expand Down
4 changes: 4 additions & 0 deletions nas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@
tags:
- esphome

- role: evershop
tags:
- evershop

- role: excalidraw
tags:
- excalidraw
Expand Down
35 changes: 35 additions & 0 deletions roles/evershop/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
evershop_enabled: false
evershop_available_externally: false

# directories
evershop_data_directory: "{{ docker_home }}/evershop"

# network
evershop_port: "3023"
evershop_hostname: "evershop"
evershop_network_name: "evershop"

# specs
evershop_memory: 1g
evershop_postgres_memory: 1g

# docker
evershop_container_name: evershop
evershop_postgres_container_name: evershop-db
evershop_image_name: "evershop/evershop"
evershop_image_version: latest
evershop_postgres_image_name: "postgres"
evershop_postgres_image_version: "16"
evershop_user_id: "1000"
evershop_group_id: "1000"

# evershop
evershop_db_name: "evershop"
evershop_db_username: "evershop"
evershop_db_password: "secure"
evershop_db_host: "{{ evershop_postgres_container_name }}"
evershop_db_port: "5432"
evershop_admin_email: "admin@{{ ansible_nas_domain }}"
evershop_admin_name: "admin"
evershop_admin_password: "supersecure"
11 changes: 11 additions & 0 deletions roles/evershop/docs/evershop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Evershop

Homepage: [https://github.com/evershopcommerce/evershop](https://github.com/evershopcommerce/evershop)

NodeJS E-commerce Platform

## Usage

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

evershop web interface can be found at [http://ansible_nas_host_or_ip:3023](http://ansible_nas_host_or_ip:3023).
16 changes: 16 additions & 0 deletions roles/evershop/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
platforms:
- name: instance
image: geerlingguy/docker-ubuntu2204-ansible:latest
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /var/run/docker.sock:/var/run/docker.sock
- /tmp:/tmp
privileged: true
pre_build_image: true
provisioner:
inventory:
group_vars:
all:
evershop_enabled: true
evershop_data_directory: /tmp/evershop
10 changes: 10 additions & 0 deletions roles/evershop/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:
evershop_enabled: false
26 changes: 26 additions & 0 deletions roles/evershop/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 evershop postgres container state
community.docker.docker_container:
name: "{{ evershop_postgres_container_name }}"
register: result_db

- name: Get evershop container state
community.docker.docker_container:
name: "{{ evershop_container_name }}"
register: result

- name: Check if evershop 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/evershop/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 evershop postgres
community.docker.docker_container:
name: "{{ evershop_postgres_container_name }}"
state: absent
register: result_db

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

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

- name: Create Evershop network
community.docker.docker_network:
name: "{{ evershop_network_name }}"

- name: Create Evershop Postgress Docker Container
community.docker.docker_container:
name: "{{ evershop_postgres_container_name }}"
image: "{{ evershop_postgres_image_name }}:{{ evershop_postgres_image_version }}"
pull: true
volumes:
- "{{ evershop_data_directory }}/database:/var/lib/postgresql/data:rw"
networks:
- name: "{{ evershop_network_name }}"
network_mode: "{{ evershop_network_name }}"
container_default_behavior: no_defaults
env:
POSTGRES_PASSWORD: "{{ evershop_db_password }}"
POSTGRES_USER: "{{ evershop_db_username }}"
POSTGRES_DB: "{{ evershop_db_name }}"
PG_DATA: /var/lib/postgresql/data
labels:
traefik.enable: "false"
restart_policy: always
memory: "{{ evershop_postgres_memory }}"
healthcheck:
test: ["CMD-SHELL", "pg_isready -d {{ evershop_db_name }} -U {{ evershop_db_username }}"]
start_period: 20s
interval: 30s
retries: 5
timeout: 5s

- name: Create Evershop Docker Container
community.docker.docker_container:
container_default_behavior: no_defaults
name: "{{ evershop_container_name }}"
image: "{{ evershop_image_name }}:{{ evershop_image_version }}"
pull: true
volumes:
- "{{ evershop_data_directory }}/data/config:/app/config:rw"
- "{{ evershop_data_directory }}/data/media:/app/media:rw"
- "{{ evershop_data_directory }}/data/public:/app/public:rw"
- "{{ evershop_data_directory }}/data/themes:/app/themes:rw"
networks:
- name: "{{ evershop_network_name }}"
network_mode: "{{ evershop_network_name }}"
ports:
- "{{ evershop_port }}:3000"
env:
DB_HOST: "{{ evershop_db_host }}"
DB_PORT: "{{ evershop_db_port }}"
DB_PASSWORD: "{{ evershop_db_password }}"
DB_USER: "{{ evershop_db_username }}"
DB_NAME: "{{ evershop_db_name }}"
NODE_ENV: production
restart_policy: unless-stopped
memory: "{{ evershop_memory }}"
labels:
traefik.enable: "{{ evershop_available_externally | string }}"
traefik.http.routers.evershop.rule: "Host(`{{ evershop_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.evershop.tls.certresolver: "letsencrypt"
traefik.http.routers.evershop.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.evershop.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.evershop.loadbalancer.server.port: "3000"

- name: Create new admin user
community.docker.docker_container_exec:
container: "{{ evershop_container_name }}"
command: npm run user:create -- --email "{{ evershop_admin_email }}" --password "{{ evershop_admin_password }}" --name "{{ evershop_admin_name }}"
tags: molecule-idempotence-notest
when: evershop_enabled is true

- name: Stop Evershop
block:
- name: Stop Evershop postgres
community.docker.docker_container:
name: "{{ evershop_postgres_container_name }}"
state: absent

- name: Stop Evershop
community.docker.docker_container:
name: "{{ evershop_container_name }}"
state: absent
when: evershop_enabled is false
14 changes: 14 additions & 0 deletions website/docs/applications/content-management/evershop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: "Evershop"
description: "NodeJS E-commerce Platform"
---

Homepage: [https://github.com/evershopcommerce/evershop](https://github.com/evershopcommerce/evershop)

NodeJS E-commerce Platform

## Usage

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

evershop web interface can be found at [http://ansible_nas_host_or_ip:3023](http://ansible_nas_host_or_ip:3023).

0 comments on commit d6b6d05

Please sign in to comment.