From 6fc0b51fe9b7128418ca162a2293d42f7b6bf907 Mon Sep 17 00:00:00 2001
From: anima
Date: Sun, 11 Jun 2023 21:33:35 +0200
Subject: [PATCH] inital setup
---
.env.sample | 12 ++++++++
.gitignore | 2 ++
README.md | 69 +++++++++++++++++++++++++++++++++++++++++-
docker-compose.yml | 75 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 157 insertions(+), 1 deletion(-)
create mode 100644 .env.sample
create mode 100644 .gitignore
create mode 100644 docker-compose.yml
diff --git a/.env.sample b/.env.sample
new file mode 100644
index 0000000..5cfc42d
--- /dev/null
+++ b/.env.sample
@@ -0,0 +1,12 @@
+WIKITAG=2
+DBTAG=10.6
+SEARCHTAG=7.17.10
+
+INTRANET=
+
+DB_TYPE=
+DB_HOST=
+DB_PORT=
+DBNAME=
+DB_USER=
+DB_PASS=
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6f020d6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.env
+files/
\ No newline at end of file
diff --git a/README.md b/README.md
index cbec12f..5f23e13 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,69 @@
-# compose-wikijs
+# Basic Wiki.js with MariaDB and Elasticsearch docker-compose config
+* can be run on single node setup or in swarm
+## howto
+### single node
+#### start container
+```bash
+docker compose up -d
+```
+
+#### stop container (and remove)
+```bash
+docker compose down
+```
+
+#### view logs
+```bash
+docker compose logs -f
+```
+
+#### reload config
+```bash
+docker compose restart
+```
+
+### swarm
+#### start aka deploy
+hint: drone fails to start until git auth source is created and set in vars
+```bash
+docker stack deploy -c docker-compose.yml wiki
+```
+
+#### stop container aka stack
+```bash
+docker stack rm wiki
+```
+
+#### view logs
+```bash
+docker service logs wiki_wiki -f
+docker service logs wiki_db -f
+docker service logs wiki_elastic -f
+```
+
+#### reload config (no downtime if replica 2 or more)
+```bash
+docker service update wiki_wiki
+docker service update wiki_db
+docker service update wiki_elastic
+```
+
+## example caddy config
+```
+wiki.example.com {
+ reverse_proxy wiki:3000
+}
+```
+
+## config elastic search engin
+1) Goto: Adminpanel => Search Engin
+2) Select Elasticsearch
+ - Elasticsearch Version: 7.x
+ - Hosts: http://elastic:9300
+ - Index Name: wiki
+3) Save with "Apply"
+4) Hit "Rebuild index"
+
+## source
+- https://www.lucadentella.it/en/2022/05/10/wiki-js-ricerca-full-text-con-elasticsearch/
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..021f614
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,75 @@
+# https://docs.docker.com/compose/compose-file/compose-file-v3/
+---
+version: "3.9"
+services:
+ wiki:
+ image: requarks/wiki:${WIKITAG:-latest}
+ container_name: wiki
+ restart: unless-stopped
+ depends_on:
+ - db
+ - elastic
+ ports:
+ - 3000:3000
+ deploy:
+ replicas: 1
+ placement:
+ max_replicas_per_node: 1
+ update_config:
+ parallelism: 1
+ delay: 10s
+ # volumes: # only need if using sqlite
+ # - ${BASEDIR:-.}/files/data/:/data/
+ # - ${BASEDIR:-.}/files/config/:/config/
+ environment:
+ - DB_TYPE=${DB_TYPE:-mariadb}
+ - DB_HOST=${DB_HOST:-db}
+ - DB_PORT=${DB_PORT:-3306}
+ - DB_NAME=${DBNAME:-wikijs}
+ - DB_USER=${DB_USER:-wikijs}
+ - DB_PASS=${DB_PASS:-wikijspasswd}
+ networks:
+ - backend
+ - wikinet
+
+ db:
+ image: mariadb:${DBTAG:-latest}
+ container_name: wikidb
+ restart: unless-stopped
+ deploy:
+ replicas: 1
+ placement:
+ max_replicas_per_node: 1
+ update_config:
+ parallelism: 1
+ delay: 10s
+ volumes:
+ - ${BASEDIR:-.}/files/db/:/var/lib/mysql/
+ environment:
+ - MARIADB_RANDOM_ROOT_PASSWORD=yes
+ - MARIADB_DATABASE=${DB_NAME:-wikijs}
+ - MARIADB_USER=${DB_USER:-wikijs}
+ - MARIADB_PASSWORD=${DB_PASS:-wikijspasswd}
+ networks:
+ - wikinet
+
+ elastic:
+ image: elasticsearch:${SEARCHTAG:-latest}
+ container_name: elastic
+ deploy:
+ replicas: 1
+ placement:
+ max_replicas_per_node: 1
+ update_config:
+ parallelism: 1
+ delay: 10s
+ environment:
+ - xpack.security.enabled=false
+ - "discovery.type=single-node"
+ networks:
+ - wikinet
+
+networks:
+ backend:
+ name: ${INTRANET:-backend}
+ wikinet:
\ No newline at end of file