tests - refactor mattermost example

This commit is contained in:
florian 2022-07-22 19:48:31 +02:00
parent 4e7d795ea6
commit 1513785705
8 changed files with 175 additions and 2 deletions

View File

@ -1,5 +1,5 @@
{
"name": "load-balancer",
"name": "magento",
"kinds": [
"docker",
"autoconf",
@ -14,4 +14,4 @@
"string": "hello"
}
]
}
}

View File

@ -0,0 +1,93 @@
version: '3'
services:
mattermost:
depends_on:
- postgres
image: mattermost/${MATTERMOST_IMAGE}:${MATTERMOST_IMAGE_TAG}
restart: ${RESTART_POLICY}
security_opt:
- no-new-privileges:true
pids_limit: 200
read_only: ${MATTERMOST_CONTAINER_READONLY}
tmpfs:
- /tmp
networks:
bw-services:
aliases:
- mattermost
volumes:
- ${MATTERMOST_CONFIG_PATH}:/mattermost/config:rw
- ${MATTERMOST_DATA_PATH}:/mattermost/data:rw
- ${MATTERMOST_LOGS_PATH}:/mattermost/logs:rw
- ${MATTERMOST_PLUGINS_PATH}:/mattermost/plugins:rw
- ${MATTERMOST_CLIENT_PLUGINS_PATH}:/mattermost/client/plugins:rw
- ${MATTERMOST_BLEVE_INDEXES_PATH}:/mattermost/bleve-indexes:rw
# When you want to use SSO with GitLab, you have to add the cert pki chain of GitLab inside Alpine
# to avoid Token request failed: certificate signed by unknown authority
# (link: https://github.com/mattermost/mattermost-server/issues/13059 and https://github.com/mattermost/docker/issues/34)
# - ${GITLAB_PKI_CHAIN_PATH}:/etc/ssl/certs/pki_chain.pem:ro
environment:
# timezone inside container
- TZ
# necessary Mattermost options/variables (see env.example)
- MM_SQLSETTINGS_DRIVERNAME
- MM_SQLSETTINGS_DATASOURCE
# necessary for bleve
- MM_BLEVESETTINGS_INDEXDIR
# additional settings
- MM_SERVICESETTINGS_SITEURL
labels:
- bunkerweb.MAX_CLIENT_SIZE=50m
# Methods used to query the api
# more info at https://api.mattermost.com/
- bunkerweb.ALLOWED_METHODS=GET|POST|HEAD|DELETE|PUT
# Reverse proxy to Mattermost
# second endpoint needs websocket enabled
# more info at https://docs.mattermost.com/install/config-proxy-nginx.html
- bunkerweb.USE_REVERSE_PROXY=yes
- bunkerweb.REVERSE_PROXY_INTERCEPT_ERRORS=no
- bunkerweb.REVERSE_PROXY_URL_1=/
- bunkerweb.REVERSE_PROXY_HOST_1=http://mattermost:8065
- bunkerweb.REVERSE_PROXY_URL_2=~ /api/v[0-9]+/(users/)?websocket$$
- bunkerweb.REVERSE_PROXY_HOST_2=http://mattermost:8065
- bunkerweb.REVERSE_PROXY_WS_2=yes
# Default limit rate for URLs
- bunkerweb.LIMIT_REQ_URL_1=/
- bunkerweb.LIMIT_REQ_RATE_1=3r/s
# Limit rate for api endpoints
- bunkerweb.LIMIT_REQ_URL_2=^/api/
- bunkerweb.LIMIT_REQ_RATE_2=10r/s
# Limit rate for static resources
- bunkerweb.LIMIT_REQ_URL_3=^/static/
- bunkerweb.LIMIT_REQ_RATE_3=10r/s
postgres:
image: postgres:${POSTGRES_IMAGE_TAG}
networks:
bw-services:
aliases:
- postgres
restart: ${RESTART_POLICY}
security_opt:
- no-new-privileges:true
pids_limit: 100
read_only: true
tmpfs:
- /tmp
- /var/run/postgresql
volumes:
- ${POSTGRES_DATA_PATH}:/var/lib/postgresql/data
environment:
# timezone inside container
- TZ
# necessary Postgres options/variables
- POSTGRES_USER
- POSTGRES_PASSWORD
- POSTGRES_DB
networks:
bw-services:
external:
name: bw-services

View File

@ -0,0 +1,8 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi
helm delete mattermost

View File

@ -0,0 +1,36 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress
annotations:
bunkerweb.io/AUTO_LETS_ENCRYPT: "yes"
bunkerweb.io/www.example.com_MAX_CLIENT_SIZE: "50m"
# Methods used to query the api
# more info at https://api.mattermost.com/
bunkerweb.io/www.example.com_ALLOWED_METHODS: "GET|POST|HEAD|DELETE|PUT"
# Reverse proxy to Mattermost
# second endpoint needs websocket enabled
# more info at https://docs.mattermost.com/install/config-proxy-nginx.html
bunkerweb.io/www.example.com_REVERSE_PROXY_INTERCEPT_ERRORS: "no"
bunkerweb.io/www.example.com_REVERSE_PROXY_WS_1: "yes"
# Default limit rate for URLs
bunkerweb.io/www.example.com_LIMIT_REQ_URL_1: "/"
bunkerweb.io/www.example.com_LIMIT_REQ_RATE_1: "3r/s"
# Limit rate for api endpoints
bunkerweb.io/www.example.com_LIMIT_REQ_URL_2: "^/api/"
bunkerweb.io/www.example.com_LIMIT_REQ_RATE_2: "10r/s"
# Limit rate for static resources
bunkerweb.io/www.example.com_LIMIT_REQ_URL_3: "^/static/"
bunkerweb.io/www.example.com_LIMIT_REQ_RATE_3: "10r/s"
spec:
rules:
- host: www.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: mattermost
port:
number: 8065

View File

@ -0,0 +1,11 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi
if [ ! -d ./volumes/app/mattermost ] ; then
mkdir -p ./volumes/app/mattermost/{config,data,logs,plugins,client/plugins,bleve-indexes}
fi
chown -R 2000:2000 ./volumes/app/mattermost

View File

@ -0,0 +1,9 @@
#!/bin/bash
if [ $(id -u) -ne 0 ] ; then
echo "❌ Run me as root"
exit 1
fi
helm repo add mattermost https://helm.mattermost.com
helm install mattermost mattermost/mattermost-team-edition

View File

@ -0,0 +1,16 @@
{
"name": "mattermost",
"kinds": [
"docker",
"autoconf",
"kubernetes"
],
"timeout": 60,
"tests": [
{
"type": "string",
"url": "https://www.example.com",
"string": "mattermost"
}
]
}