From d4007c43ceb57cfa8b36ed0ac02cd3e5147add95 Mon Sep 17 00:00:00 2001 From: william chandra Date: Tue, 19 Sep 2023 08:15:54 +0700 Subject: [PATCH] add gitops --- gitops/erpnext-one.env | 52 +++++++++ gitops/erpnext-one.yaml | 236 ++++++++++++++++++++++++++++++++++++++++ gitops/mariadb.env | 1 + gitops/traefik.env | 3 + 4 files changed, 292 insertions(+) create mode 100644 gitops/erpnext-one.env create mode 100644 gitops/erpnext-one.yaml create mode 100644 gitops/mariadb.env create mode 100644 gitops/traefik.env diff --git a/gitops/erpnext-one.env b/gitops/erpnext-one.env new file mode 100644 index 00000000..117ae281 --- /dev/null +++ b/gitops/erpnext-one.env @@ -0,0 +1,52 @@ +# Reference: https://github.com/frappe/frappe_docker/blob/main/docs/images-and-compose-files.md + +ERPNEXT_VERSION=v14.37.1 + +DB_PASSWORD=specialwaytodie + +# Only if you use external database +DB_HOST=mariadb-database +DB_PORT=3306 + +# Only if you use external Redis +REDIS_CACHE= +REDIS_QUEUE= +REDIS_SOCKETIO= + +# Only with HTTPS override +LETSENCRYPT_EMAIL=mail@example.com + +# These environment variables are not required. + +# Default value is `$$host` which resolves site by host. For example, if your host is `example.com`, +# site's name should be `example.com`, or if host is `127.0.0.1` (local debugging), it should be `127.0.0.1`. +# This variable allows to override described behavior. Let's say you create site named `mysite` +# and do want to access it by `127.0.0.1` host. Than you would set this variable to `mysite`. +FRAPPE_SITE_NAME_HEADER= + +# Default value is `127.0.0.1`. Set IP address as our trusted upstream address. +UPSTREAM_REAL_IP_ADDRESS= + +# Default value is `X-Forwarded-For`. Set request header field whose value will be used to replace the client address +UPSTREAM_REAL_IP_HEADER= + +# Allowed values are on|off. Default value is `off`. If recursive search is disabled, +# the original client address that matches one of the trusted addresses +# is replaced by the last address sent in the request header field defined by the real_ip_header directive. +# If recursive search is enabled, the original client address that matches one of the trusted addresses is replaced by the last non-trusted address sent in the request header field. +UPSTREAM_REAL_IP_RECURSIVE= + +# All Values Allowed by nginx proxy_read_timeout are allowed, default value is 120s +# Useful if you have longrunning print formats or slow loading sites +PROXY_READ_TIMEOUT= + +# All Values allowed by nginx client_max_body_size are allowed, default value is 50m +# Necessary if the upload limit in the frappe application is increased +CLIENT_MAX_BODY_SIZE= + +# List of sites for letsencrypt certificates quoted with backtick (`) and separated by comma (,) +# More https://doc.traefik.io/traefik/routing/routers/#rule +# About acme https://doc.traefik.io/traefik/https/acme/#domain-definition +SITES=`erp-next.localhost` +ROUTER=erpnext-one +BENCH_NETWORK=erpnext-one \ No newline at end of file diff --git a/gitops/erpnext-one.yaml b/gitops/erpnext-one.yaml new file mode 100644 index 00000000..4b31112c --- /dev/null +++ b/gitops/erpnext-one.yaml @@ -0,0 +1,236 @@ +name: erpnext-one +services: + backend: + depends_on: + configurator: + condition: service_completed_successfully + required: true + image: frappe/erpnext:v14.37.1 + networks: + bench-network: null + mariadb-network: null + volumes: + - type: volume + source: sites + target: /home/frappe/frappe-bench/sites + volume: {} + configurator: + command: + - | + ls -1 apps > sites/apps.txt; bench set-config -g db_host $$DB_HOST; bench set-config -gp db_port $$DB_PORT; bench set-config -g redis_cache "redis://$$REDIS_CACHE"; bench set-config -g redis_queue "redis://$$REDIS_QUEUE"; bench set-config -g redis_socketio "redis://$$REDIS_SOCKETIO"; bench set-config -gp socketio_port $$SOCKETIO_PORT; + depends_on: + redis-cache: + condition: service_started + required: true + redis-queue: + condition: service_started + required: true + redis-socketio: + condition: service_started + required: true + entrypoint: + - bash + - -c + environment: + DB_HOST: mariadb-database + DB_PORT: "3306" + REDIS_CACHE: redis-cache:6379 + REDIS_QUEUE: redis-queue:6379 + REDIS_SOCKETIO: redis-socketio:6379 + SOCKETIO_PORT: "9000" + image: frappe/erpnext:v14.37.1 + networks: + bench-network: null + mariadb-network: null + volumes: + - type: volume + source: sites + target: /home/frappe/frappe-bench/sites + volume: {} + frontend: + command: + - nginx-entrypoint.sh + depends_on: + backend: + condition: service_started + required: true + websocket: + condition: service_started + required: true + environment: + BACKEND: backend:8000 + CLIENT_MAX_BODY_SIZE: 50m + FRAPPE_SITE_NAME_HEADER: $$host + PROXY_READ_TIMOUT: "120" + SOCKETIO: websocket:9000 + UPSTREAM_REAL_IP_ADDRESS: 127.0.0.1 + UPSTREAM_REAL_IP_HEADER: X-Forwarded-For + UPSTREAM_REAL_IP_RECURSIVE: "off" + image: frappe/erpnext:v14.37.1 + labels: + traefik.docker.network: traefik-public + traefik.enable: "true" + traefik.http.routers.erpnext-one-http.entrypoints: http + traefik.http.routers.erpnext-one-http.rule: Host(`erp-next.localhost`) + traefik.http.routers.erpnext-one-http.service: erpnext-one + traefik.http.services.erpnext-one.loadbalancer.server.port: "8080" + networks: + bench-network: null + traefik-public: null + volumes: + - type: volume + source: sites + target: /home/frappe/frappe-bench/sites + volume: {} + queue-default: + command: + - bench + - worker + - --queue + - default + depends_on: + configurator: + condition: service_completed_successfully + required: true + image: frappe/erpnext:v14.37.1 + networks: + bench-network: null + mariadb-network: null + volumes: + - type: volume + source: sites + target: /home/frappe/frappe-bench/sites + volume: {} + queue-long: + command: + - bench + - worker + - --queue + - long + depends_on: + configurator: + condition: service_completed_successfully + required: true + image: frappe/erpnext:v14.37.1 + networks: + bench-network: null + mariadb-network: null + volumes: + - type: volume + source: sites + target: /home/frappe/frappe-bench/sites + volume: {} + queue-short: + command: + - bench + - worker + - --queue + - short + depends_on: + configurator: + condition: service_completed_successfully + required: true + image: frappe/erpnext:v14.37.1 + networks: + bench-network: null + mariadb-network: null + volumes: + - type: volume + source: sites + target: /home/frappe/frappe-bench/sites + volume: {} + redis-cache: + image: redis:6.2-alpine + networks: + bench-network: null + mariadb-network: null + volumes: + - type: volume + source: redis-cache-data + target: /data + volume: {} + redis-queue: + image: redis:6.2-alpine + networks: + bench-network: null + mariadb-network: null + volumes: + - type: volume + source: redis-queue-data + target: /data + volume: {} + redis-socketio: + image: redis:6.2-alpine + networks: + bench-network: null + mariadb-network: null + volumes: + - type: volume + source: redis-socketio-data + target: /data + volume: {} + scheduler: + command: + - bench + - schedule + depends_on: + configurator: + condition: service_completed_successfully + required: true + image: frappe/erpnext:v14.37.1 + networks: + bench-network: null + mariadb-network: null + volumes: + - type: volume + source: sites + target: /home/frappe/frappe-bench/sites + volume: {} + websocket: + command: + - node + - /home/frappe/frappe-bench/apps/frappe/socketio.js + depends_on: + configurator: + condition: service_completed_successfully + required: true + image: frappe/erpnext:v14.37.1 + networks: + bench-network: null + mariadb-network: null + volumes: + - type: volume + source: sites + target: /home/frappe/frappe-bench/sites + volume: {} +networks: + bench-network: + name: erpnext-one + mariadb-network: + name: mariadb-network + external: true + traefik-public: + name: traefik-public + external: true +volumes: + redis-cache-data: + name: erpnext-one_redis-cache-data + redis-queue-data: + name: erpnext-one_redis-queue-data + redis-socketio-data: + name: erpnext-one_redis-socketio-data + sites: + name: erpnext-one_sites +x-backend-defaults: + depends_on: + configurator: + condition: service_completed_successfully + image: frappe/erpnext:v14.37.1 + volumes: + - sites:/home/frappe/frappe-bench/sites +x-customizable-image: + image: frappe/erpnext:v14.37.1 +x-depends-on-configurator: + depends_on: + configurator: + condition: service_completed_successfully diff --git a/gitops/mariadb.env b/gitops/mariadb.env new file mode 100644 index 00000000..71860f2d --- /dev/null +++ b/gitops/mariadb.env @@ -0,0 +1 @@ +DB_PASSWORD=specialwaytodie diff --git a/gitops/traefik.env b/gitops/traefik.env new file mode 100644 index 00000000..80394b77 --- /dev/null +++ b/gitops/traefik.env @@ -0,0 +1,3 @@ +TRAEFIK_DOMAIN="traefik.localhost" +EMAIL="admin@example.com" +HASHED_PASSWORD="\$apr1\$4teEiPk3\$GoOFFn1.jAMTSTxxFgO1j/"