Skip to content

Commit 18fadb6

Browse files
authored
Modularize docker stack: allow loading of addiditional scenarios (#467)
* Modularize docker stack: allow loading of addiditional scenarios * Activate elasticsearch security / authentication
1 parent eba50df commit 18fadb6

37 files changed

+418
-162
lines changed

.env.dist

+68-12
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
1+
#############################################
12
# Docker Environment Variables
23
# https://docs.zammad.org/en/latest/install/docker-compose/environment.html
4+
#############################################
35

4-
# ELASTICSEARCH_VERSION=8.17.1
6+
#############################################
7+
# docker-compose.yml - These variables only need to be set if they do not have the default value.
8+
#############################################
9+
10+
# RESTART=always
11+
12+
# Use a fixed Zammad version rather than the default. If you do so,
13+
# you are responsible to update this to newer patch level versions yourself.
14+
# VERSION=6.4.1-45
15+
# You can also use floating versions that will give you automatic updates:
16+
# VERSION=6.2 # all patchlevel updates
17+
# VERSION=6 # including minor updates
18+
# VERSION=latest # all updates of stable versions, including major
19+
# VERSION=develop # bleeding-edge development version
520
# IMAGE_REPO=ghcr.io/zammad/zammad
21+
22+
# ELASTICSEARCH_VERSION=8.17.1
623
# MEMCACHE_SERVERS=zammad-memcached:11211
724
# MEMCACHE_VERSION=1.6.36-alpine
25+
# REDIS_URL=redis://zammad-redis:6379
26+
# REDIS_VERSION=7.4.2-alpine
27+
# POSTGRES_VERSION=17.2-alpine
28+
29+
# RAILS_TRUSTED_PROXIES=
30+
# ZAMMAD_HTTP_TYPE=
31+
# ZAMMAD_FQDN=
32+
833
# NGINX_PORT=8080
934
# NGINX_EXPOSE_PORT=8080
1035
# NGINX_CLIENT_MAX_BODY_SIZE=50M
@@ -13,15 +38,46 @@
1338
# POSTGRES_USER=zammad
1439
# POSTGRES_HOST=zammad-postgresql
1540
# POSTGRES_PORT=5432
16-
# POSTGRES_VERSION=17.2-alpine
1741
# POSTGRESQL_OPTIONS=?pool=50
18-
# REDIS_URL=redis://zammad-redis:6379
19-
# REDIS_VERSION=7.4.2-alpine
20-
# RESTART=always
21-
# Use a fixed version. You are responsible to update this to newer patch level versions yourself.
22-
# VERSION=6.4.1-45
23-
# You can also use floating versions that will give you automatic updates:
24-
# VERSION=6.2 # all patchlevel updates
25-
# VERSION=6 # including minor updates
26-
# VERSION=latest # all updates of stable versions, including major
27-
# VERSION=develop # bleeding-edge development version
42+
43+
# ELASTICSEARCH_SCHEMA=http
44+
# ELASTICSEARCH_HOST=zammad-elasticsearch
45+
# ELASTICSEARCH_PORT=9200
46+
# ELASTICSEARCH_USER=elastic
47+
# ELASTICSEARCH_PASS=zammad
48+
# ELASTICSEARCH_NAMESPACE=zammad
49+
# ELASTICSEARCH_REINDEX=true
50+
51+
# Variables used by ngingx-proxy container for reverse proxy creations,
52+
# for docs refer to https://github.com/nginx-proxy/nginx-proxy.
53+
# VIRTUAL_HOST=
54+
# VIRTUAL_PORT=
55+
# Variables used by acme-companion for retrieval of LetsEncrypt certificate,
56+
# for docs refer to https://github.com/nginx-proxy/acme-companion.
57+
# LETSENCRYPT_HOST=
58+
# LETSENCRYPT_EMAIL=
59+
60+
#############################################
61+
# scenarios/add-cloudflare-tunnel.yml
62+
#############################################
63+
64+
# CLOUDFLARE_TUNNEL_TOKEN=mytoken
65+
66+
#############################################
67+
# scenarios/add-external-network-to-nginx.yml
68+
#############################################
69+
70+
# ZAMMAD_NGINX_EXTERNAL_NETWORK=mynetwork
71+
72+
#############################################
73+
# scenarios/add-external-network-to-elasticsearch.yml
74+
#############################################
75+
76+
# ZAMMAD_ELASTICSEARCH_EXTERNAL_NETWORK=mynetwork
77+
78+
#############################################
79+
# scenarios/add-hostport-to-elasticsearch.yml
80+
#############################################
81+
82+
# Defaults to 9200, set this if you need another value.
83+
# ELASTICSEARCH_EXPOSE_HTTP_PORT=9200

.examples/proxy/certs/.gitkeep

Whitespace-only changes.

.examples/proxy/docker-compose.proxy-example.yml

-16
This file was deleted.

.examples/proxy/docker-compose.yml

-18
This file was deleted.

.github/linters/.yaml-lint.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
rules:
3+
line-length:
4+
max: 120
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
# shellcheck source=/dev/null
4+
. "$(dirname "$0")/include/functions.sh"
5+
6+
check_stack_start
7+
8+
print_heading "check for presence cloudflare tunnel container"
9+
docker compose ps | grep cloudflare-tunnel
10+
print_heading "Success - cloudflare container is present"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
# shellcheck source=/dev/null
4+
. "$(dirname "$0")/include/functions.sh"
5+
6+
check_stack_start
7+
8+
print_heading "check for presence of external network"
9+
docker inspect zammad-docker-compose-zammad-elasticsearch-1 | grep zammad-ci-external-network
10+
print_heading "Success - external network is present"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
# shellcheck source=/dev/null
4+
. "$(dirname "$0")/include/functions.sh"
5+
6+
check_stack_start
7+
8+
print_heading "check for presence of external network"
9+
docker inspect zammad-docker-compose-zammad-nginx-1 | grep zammad-ci-external-network
10+
print_heading "Success - external network is present"
11+
12+
print_heading "check that nginx is not exposed on the Host"
13+
docker inspect zammad-docker-compose-zammad-nginx-1 | grep HostPort && exit 1
14+
print_heading "Success - nginx is not exposed on the host"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
# shellcheck source=/dev/null
4+
. "$(dirname "$0")/include/functions.sh"
5+
6+
check_stack_start
7+
8+
print_heading "check for hostport"
9+
docker inspect zammad-docker-compose-zammad-elasticsearch-1 | grep HostPort | grep 9201
10+
print_heading "Success - hostport is present"
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
# shellcheck source=/dev/null
4+
. "$(dirname "$0")/include/functions.sh"
5+
6+
check_stack_start
7+
8+
print_heading "check for presence nginx-proxy-manager container"
9+
docker compose ps | grep nginx-proxy-manager
10+
print_heading "Success - nginx-proxy-manager container is present"

.github/tests.sh renamed to .github/tests/default.sh

+3-23
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,9 @@
11
#!/bin/sh
2-
#
3-
# run zammad tests
4-
#
52

6-
set -o errexit
3+
# shellcheck source=/dev/null
4+
. "$(dirname "$0")/include/functions.sh"
75

8-
# Send the logs to STDOUT for debugging.
9-
docker compose logs --timestamps --follow &
10-
11-
# Print empty lines before and after the heading to find it between the logs.
12-
print_heading() {
13-
echo ">"
14-
echo "> $1"
15-
echo ">"
16-
}
17-
18-
# Run commands in the zammad-railsserver container in a way that also allows the rails stack to start.
19-
railsserver_run_command() {
20-
docker compose exec --env=AUTOWIZARD_RELATIVE_PATH=tmp/auto_wizard.json --env=DATABASE_URL=postgres://zammad:zammad@zammad-postgresql:5432/zammad_production zammad-railsserver "$@"
21-
}
22-
23-
print_heading "wait for zammad to be ready…"
24-
docker compose wait zammad-init
25-
docker compose exec zammad-nginx bash -c "curl --retry 30 --retry-delay 1 --retry-connrefused http://localhost:8080 | grep 'Zammad'"
26-
print_heading "Success - Zammad is up :)"
6+
check_stack_start
277

288
# Checking for external connectivity may not always be possible, e.g. in GitLab CI.
299
if [ -z "$DISABLE_EXTERNAL_TESTS" ]
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
# shellcheck source=/dev/null
4+
. "$(dirname "$0")/include/functions.sh"
5+
6+
check_stack_start
7+
8+
print_heading "check for absence of backup container"
9+
docker compose ps | grep zammad-backup && exit 1
10+
print_heading "Success - backup container is absent"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
# shellcheck source=/dev/null
4+
. "$(dirname "$0")/include/functions.sh"
5+
6+
check_stack_start
7+
8+
print_heading "check for absence of elasticsearch container"
9+
docker compose ps | grep zammad-elasticsearch && exit 1
10+
print_heading "Success - elasticsearch container is absent"

.github/tests/include/functions.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
set -o errexit
4+
5+
# Send the logs to STDOUT for debugging.
6+
docker compose logs --timestamps --follow &
7+
8+
# Print empty lines before and after the heading to find it between the logs.
9+
print_heading() {
10+
echo ">"
11+
echo "> $1"
12+
echo ">"
13+
}
14+
15+
# Run commands in the zammad-railsserver container in a way that also allows the rails stack to start.
16+
railsserver_run_command() {
17+
docker compose exec --env=AUTOWIZARD_RELATIVE_PATH=tmp/auto_wizard.json --env=DATABASE_URL=postgres://zammad:zammad@zammad-postgresql:5432/zammad_production zammad-railsserver "$@"
18+
}
19+
20+
check_stack_start() {
21+
print_heading "wait for zammad to be ready…"
22+
docker compose wait zammad-init
23+
docker compose exec zammad-nginx bash -c "curl --retry 30 --retry-delay 1 --retry-connrefused http://localhost:8080 | grep 'Zammad'"
24+
print_heading "Success - Zammad is up :)"
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
set -o errexit
4+
5+
docker network create zammad-ci-external-network
6+
7+
echo "CLOUDFLARE_TUNNEL_TOKEN=invalid-token" > .env
8+
9+
docker compose -f docker-compose.yml -f scenarios/add-cloudflare-tunnel.yml up --quiet-pull --detach
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
set -o errexit
4+
5+
docker network create zammad-ci-external-network
6+
7+
echo "ZAMMAD_ELASTICSEARCH_EXTERNAL_NETWORK=zammad-ci-external-network" > .env
8+
9+
docker compose -f docker-compose.yml -f scenarios/add-external-network-to-elasticsearch.yml up --quiet-pull --detach
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
set -o errexit
4+
5+
docker network create zammad-ci-external-network
6+
7+
echo "ZAMMAD_NGINX_EXTERNAL_NETWORK=zammad-ci-external-network" > .env
8+
9+
docker compose -f docker-compose.yml -f scenarios/add-external-network-to-nginx.yml up --quiet-pull --detach
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
set -o errexit
4+
5+
# Use a custom port to verify it is configurable.
6+
echo "ELASTICSEARCH_EXPOSE_HTTP_PORT=9201" > .env
7+
8+
docker compose -f docker-compose.yml -f scenarios/add-hostport-to-elasticsearch.yml up --quiet-pull --detach
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
set -o errexit
4+
5+
docker compose -f docker-compose.yml -f scenarios/add-nginx-proxy-manager.yml up --quiet-pull --detach

.github/tests/setup/default.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
set -o errexit
4+
5+
docker compose up --quiet-pull --detach
6+
7+
docker compose cp .github/auto_wizard.json zammad-railsserver:/opt/zammad/tmp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
set -o errexit
4+
5+
docker compose -f docker-compose.yml -f scenarios/disable-backup-service.yml up --quiet-pull --detach
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
set -o errexit
4+
5+
# Disable ES initialization in the test because we don't have an external ES service.
6+
echo "ELASTICSEARCH_ENABLED=false" > .env
7+
8+
docker compose -f docker-compose.yml -f scenarios/disable-elasticsearch-service.yml up --quiet-pull --detach

.github/workflows/ci-remote-image.yaml

-27
This file was deleted.

0 commit comments

Comments
 (0)