Compare commits
38 Commits
monotek-pa
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
799edd7863 | ||
|
6606e8e2ca | ||
|
662aa8f512 | ||
|
ffa1268a2a | ||
|
3338cbeb22 | ||
|
9a547c67a9 | ||
|
1c52589095 | ||
|
281b5f317f | ||
|
ef8830e636 | ||
|
a8911b1359 | ||
|
1f32908c23 | ||
|
360324353f | ||
|
e5b0fedfe6 | ||
|
d588f2ff65 | ||
|
01fe85d74c | ||
|
abd9cd631d | ||
|
d397322bae | ||
|
ae716aed3d | ||
|
ad516bdfd6 | ||
|
87e8b49794 | ||
|
a0aa5324dc | ||
|
731f83da2b | ||
|
c5c1db541a | ||
|
0af24d791f | ||
|
cd424e9868 | ||
|
daa1c71e00 | ||
|
52bced15fe | ||
|
225ee21d5f | ||
|
f57418a2a5 | ||
|
130f22766c | ||
|
b4779f1be0 | ||
|
10fa5096c7 | ||
|
5a65ce28cf | ||
|
d3e27a5828 | ||
|
bf95bf7fa4 | ||
|
d1a0e023c7 | ||
|
44ae0bfd18 | ||
|
893fd870d5 |
12
.env
12
.env
@ -1,8 +1,14 @@
|
||||
IMAGE_REPO=zammad/zammad-docker-compose
|
||||
ELASTICSEARCH_VERSION=8.8.0
|
||||
IMAGE_REPO=ghcr.io/zammad/zammad
|
||||
MEMCACHE_SERVERS=zammad-memcached:11211
|
||||
MEMCACHE_VERSION=1.6.20-alpine
|
||||
POSTGRES_DB=zammad_production
|
||||
POSTGRES_PASS=zammad
|
||||
POSTGRES_USER=zammad
|
||||
POSTGRES_HOST=zammad-postgresql
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_VERSION=15.3-alpine
|
||||
REDIS_URL=redis://zammad-redis:6379
|
||||
REDIS_VERSION=7.0.5-alpine
|
||||
RESTART=always
|
||||
# don't forget to add the minus before the version
|
||||
VERSION=-5.2.0-9
|
||||
VERSION=6.0.0-66
|
||||
|
16
.github/dependabot.yml
vendored
Normal file
16
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "docker"
|
||||
directory: "/containers/zammad"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
time: "09:00"
|
||||
timezone: "Europe/Berlin"
|
||||
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
time: "09:00"
|
||||
timezone: "Europe/Berlin"
|
14
.github/docker-image-build.sh
vendored
14
.github/docker-image-build.sh
vendored
@ -1,14 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# build zammads docker & docker-compose images
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
DOCKER_IMAGES="zammad zammad-elasticsearch zammad-postgresql"
|
||||
|
||||
# shellcheck disable=SC2153
|
||||
for DOCKER_IMAGE in ${DOCKER_IMAGES}; do
|
||||
echo "Build Zammad Docker image ${DOCKER_IMAGE} for local or ci tests"
|
||||
docker build --pull --no-cache --build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" -t "${DOCKER_IMAGE}-local" -f "containers/${DOCKER_IMAGE}/Dockerfile" .
|
||||
done
|
37
.github/release-drafter.yml
vendored
Normal file
37
.github/release-drafter.yml
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
name-template: "v$RESOLVED_VERSION"
|
||||
tag-template: "v$RESOLVED_VERSION"
|
||||
categories:
|
||||
- title: "🚀 Features"
|
||||
labels:
|
||||
- "feature"
|
||||
- "enhancement"
|
||||
- title: "🐛 Bug Fixes"
|
||||
labels:
|
||||
- "fix"
|
||||
- "bugfix"
|
||||
- "bug"
|
||||
- title: "🧹 Maintenance"
|
||||
labels:
|
||||
- "chore"
|
||||
- "dependencies"
|
||||
version-resolver:
|
||||
major:
|
||||
labels:
|
||||
- "feature"
|
||||
minor:
|
||||
labels:
|
||||
- "enhancement"
|
||||
patch:
|
||||
labels:
|
||||
- "fix"
|
||||
- "bugfix"
|
||||
- "bug"
|
||||
- "chore"
|
||||
- "dependencies"
|
||||
default: patch
|
||||
template: |
|
||||
## Changes
|
||||
|
||||
$CHANGES
|
||||
|
||||
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
|
16
.github/tests.sh
vendored
16
.github/tests.sh
vendored
@ -23,16 +23,28 @@ echo
|
||||
echo "Execute autowizard..."
|
||||
echo
|
||||
|
||||
docker exec zammad-docker-compose_zammad-railsserver_1 rake zammad:setup:auto_wizard
|
||||
docker exec --env=AUTOWIZARD_RELATIVE_PATH=var/auto_wizard.json --env=DATABASE_URL=postgres://zammad:zammad@zammad-postgresql:5432/zammad_production zammad-docker-compose_zammad-railsserver_1 rake zammad:setup:auto_wizard
|
||||
|
||||
echo
|
||||
echo "Autowizard executed successful :)"
|
||||
echo
|
||||
|
||||
|
||||
echo
|
||||
echo "Check DB for AutoWizard user"
|
||||
echo
|
||||
|
||||
docker exec --env=DATABASE_URL=postgres://zammad:zammad@zammad-postgresql:5432/zammad_production zammad-docker-compose_zammad-railsserver_1 rails r "p User.find_by(email: 'info@zammad.org')" | grep 'info@zammad.org'
|
||||
|
||||
echo
|
||||
echo "Check DB for AutoWizard user successfull :)"
|
||||
echo
|
||||
|
||||
echo
|
||||
echo "Fill DB with some random data"
|
||||
docker exec zammad-docker-compose_zammad-railsserver_1 rails r "FillDb.load(agents: 1,customers: 1,groups: 1,organizations: 1,overviews: 1,tickets: 1)"
|
||||
echo
|
||||
|
||||
docker exec --env=DATABASE_URL=postgres://zammad:zammad@zammad-postgresql:5432/zammad_production zammad-docker-compose_zammad-railsserver_1 rails r "FillDb.load(agents: 1,customers: 1,groups: 1,organizations: 1,overviews: 1,tickets: 1)"
|
||||
|
||||
echo
|
||||
echo "DB fill successful :)"
|
||||
|
6
.github/workflows/ci-remote-image.yaml
vendored
6
.github/workflows/ci-remote-image.yaml
vendored
@ -3,13 +3,11 @@ name: ci-remote-image
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '.env'
|
||||
|
||||
jobs:
|
||||
run-remote-image-docker-compose:
|
||||
timeout-minutes: 20
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@ -21,7 +19,7 @@ jobs:
|
||||
run: docker-compose up --detach
|
||||
|
||||
- name: add autowizard file
|
||||
run: docker cp .github/auto_wizard.json zammad-docker-compose_zammad-railsserver_1:/opt/zammad
|
||||
run: docker cp .github/auto_wizard.json zammad-docker-compose_zammad-railsserver_1:/opt/zammad/var
|
||||
|
||||
- name: run tests
|
||||
run: .github/tests.sh
|
||||
|
28
.github/workflows/ci.yaml
vendored
28
.github/workflows/ci.yaml
vendored
@ -6,7 +6,7 @@ on:
|
||||
|
||||
jobs:
|
||||
lint-docker-compose-file:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@ -15,7 +15,7 @@ jobs:
|
||||
run: docker-compose config
|
||||
|
||||
super-linter:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
@ -23,32 +23,10 @@ jobs:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Lint Code Base
|
||||
uses: github/super-linter/slim@v4
|
||||
uses: github/super-linter/slim@v5
|
||||
env:
|
||||
DEFAULT_BRANCH: master
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
LINTER_RULES_PATH: .github/linters
|
||||
VALIDATE_ALL_CODEBASE: false
|
||||
VALIDATE_JSCPD: false
|
||||
|
||||
build-and-run-docker-compose:
|
||||
needs:
|
||||
- lint-docker-compose-file
|
||||
- super-linter
|
||||
timeout-minutes: 20
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: build docker containers
|
||||
run: .github/docker-image-build.sh
|
||||
|
||||
- name: run docker-compose up
|
||||
run: docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.override-local.yml up --detach
|
||||
|
||||
- name: add autowizard file
|
||||
run: docker cp .github/auto_wizard.json zammad-docker-compose_zammad-railsserver_1:/opt/zammad
|
||||
|
||||
- name: run tests
|
||||
run: .github/tests.sh
|
||||
|
22
.github/workflows/release-drafter.yaml
vendored
Normal file
22
.github/workflows/release-drafter.yaml
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
name: Release Drafter
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
update_release_draft:
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: release-drafter/release-drafter@v5
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
58
README.md
58
README.md
@ -6,22 +6,29 @@ twitter, chat and emails. It is distributed under the GNU AFFERO General Public
|
||||
License (AGPL). Do you receive many emails and want to answer them with a team of agents?
|
||||
You're going to love Zammad!
|
||||
|
||||
## Use case for this repository
|
||||
## Use cases
|
||||
|
||||
This repository is meant to be the starting point for somebody who likes to use dockerized multi-container Zammad in production.
|
||||
This repository is the starting point if you want to:
|
||||
|
||||
## Getting started with zammad-docker-compose
|
||||
- deploy Zammad in a containerized production environment
|
||||
- test the current `stable` or `develop` versions of Zammad
|
||||
|
||||
[Learn more on Zammads documentation](https://docs.zammad.org/en/latest/install/docker-compose.html)
|
||||
## Getting started
|
||||
|
||||
[Learn more on Zammad’s documentation](https://docs.zammad.org/en/latest/install/docker-compose.html)
|
||||
|
||||
## Upgrading
|
||||
|
||||
For upgrading instructions see our [Releases](https://github.com/zammad/zammad-docker-compose/releases).
|
||||
|
||||
## Status
|
||||
|
||||
[![CI Status](https://github.com/zammad/zammad-docker-compose/workflows/ci/badge.svg)](https://github.com/zammad/zammad-docker-compose/actions) [![Docker Pulls](https://badgen.net/docker/pulls/zammad/zammad-docker-compose?icon=docker&label=pulls)](https://hub.docker.com/r/zammad/zammad-docker-compose/)
|
||||
[![ci-remote-image](https://github.com/zammad/zammad-docker-compose/actions/workflows/ci-remote-image.yaml/badge.svg)](https://github.com/zammad/zammad-docker-compose/actions/workflows/ci-remote-image.yaml) [![Dockerhub Pulls](https://badgen.net/docker/pulls/zammad/zammad-docker-compose?icon=docker&label=pulls)](https://hub.docker.com/r/zammad/zammad-docker-compose/)
|
||||
|
||||
## Using a reverse proxy
|
||||
|
||||
In environments with more then one web applications it is necessary to use a reverse proxy to route connections to port 80 and 443 to the right application.
|
||||
To run Zammad behind a revers proxy, we provide `docker-compose.proxy-example.yml` as a starting point.
|
||||
To run Zammad behind a reverse proxy, we provide `docker-compose.proxy-example.yml` as a starting point.
|
||||
|
||||
1. Copy `./.examples/proxy/docker-compose.proxy-example.yml` to your own configuration, e.g. `./docker-compose.prod.yml`
|
||||
`cp ./.examples/proxy/docker-compose.proxy-example.yml ./docker-compose.prod.yml`
|
||||
@ -42,41 +49,4 @@ RANCHER_URL=http://RANCHER_HOST:8080 rancher-compose --env-file=.env up
|
||||
|
||||
Elasticsearch is an optional, but strongly recommended dependency for Zammad. More details can be found in the [documentation](https://docs.zammad.org/en/latest/prerequisites/software.html#elasticsearch-optional). There are however certain scenarios when running without Elasticsearch may be desired, e.g. for very small teams, for teams with limited budget or as a temporary solution for an unplanned Elasticsearch downtime or planned cluster upgrade.
|
||||
|
||||
Elasticsearch is enabled by default in the example `docker-compose.yml` file. It is also by default required to run the "zammad-init" command. Disabling Elasticsearch is possible by setting a special environment variable: `ELASTICSEARCH_ENABLED=false` for the `zammad-init` container and removing all references to Elasticsearch everywhere else: the `zammad-elasticsearch` container, it's volume and links to it.
|
||||
|
||||
## Upgrading
|
||||
|
||||
### From =< 3.3.0-12
|
||||
|
||||
We've updated the Elasticsearch image from 5.6 to 7.6.
|
||||
As there is no direct upgrade path we have to delete all Elasticsearch indices and rebuild them.
|
||||
This will depend on the name of your docker container and volume, which depends on the checkout directory (`zammad-docker-compose` by default):
|
||||
|
||||
```console
|
||||
docker-compose stop
|
||||
docker container rm zammad-docker-compose_zammad-elasticsearch_1
|
||||
docker volume rm zammad-docker-compose_elasticsearch-data
|
||||
docker-compose up --no-recreate
|
||||
```
|
||||
|
||||
To workaround the [changes in the PostgreSQL 9.6 container](https://github.com/docker-library/postgres/commit/f1bc8782e7e57cc403d0b32c0e24599535859f76) do the following:
|
||||
|
||||
```console
|
||||
docker-compose start
|
||||
docker exec -it zammaddockercompose_zammad-postgresql_1 bash
|
||||
psql --username postgres --dbname zammad_production
|
||||
CREATE USER zammad;
|
||||
ALTER USER zammad WITH PASSWORD 'zammad';
|
||||
ALTER USER zammad WITH SUPERUSER CREATEDB;
|
||||
```
|
||||
|
||||
### From =< 3.6.0-65
|
||||
|
||||
To be able to run Zammad container with an unprivileged user we had to change the port Nginx uses from 80 to 8080, so Zammad needs to be accessed via <http://localhost:8080> instead of <http://localhost> now!
|
||||
|
||||
This change will also affect you, if you use a reverse proxy, like Traefik or Haproxy, in front of Zammad as your reverse proxy configuration needs to be adapted to point to port 8080 now.
|
||||
|
||||
### From =< 4.0.0 to 5.0.0
|
||||
|
||||
Memchached config changed. If you use the old env vars `MEMCACHED_HOST` & `MEMCACHED_PORT` adapt to `MEMCACHE_SERVERS`.
|
||||
Redis is a dependency for the Websocket server now.
|
||||
Elasticsearch is enabled by default in the example `docker-compose.yml` file. It is also by default required to run the "zammad-init" command. Disabling Elasticsearch is possible by setting a special environment variable: `ELASTICSEARCH_ENABLED=false` for the `zammad-init` container and removing all references to Elasticsearch everywhere else: the `zammad-elasticsearch` container, its volume and links to it.
|
||||
|
@ -1,17 +0,0 @@
|
||||
FROM docker.elastic.co/elasticsearch/elasticsearch:7.17.3
|
||||
ARG BUILD_DATE
|
||||
|
||||
LABEL org.label-schema.build-date="$BUILD_DATE" \
|
||||
org.label-schema.name="Zammad" \
|
||||
org.label-schema.license="AGPL-3.0" \
|
||||
org.label-schema.description="Docker container for Zammad - Elasticsearch" \
|
||||
org.label-schema.url="https://zammad.org" \
|
||||
org.label-schema.vcs-url="https://github.com/zammad/zammad" \
|
||||
org.label-schema.vcs-type="Git" \
|
||||
org.label-schema.vendor="Zammad" \
|
||||
org.label-schema.schema-version="5.2.0" \
|
||||
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
|
||||
|
||||
SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]
|
||||
|
||||
RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch ingest-attachment
|
@ -1,20 +0,0 @@
|
||||
FROM postgres:9.6.24-alpine
|
||||
|
||||
ARG BUILD_DATE
|
||||
|
||||
LABEL org.label-schema.build-date="$BUILD_DATE" \
|
||||
org.label-schema.name="Zammad" \
|
||||
org.label-schema.license="AGPL-3.0" \
|
||||
org.label-schema.description="Docker container for Zammad - Postgresql" \
|
||||
org.label-schema.url="https://zammad.org" \
|
||||
org.label-schema.vcs-url="https://github.com/zammad/zammad" \
|
||||
org.label-schema.vcs-type="Git" \
|
||||
org.label-schema.vendor="Zammad" \
|
||||
org.label-schema.schema-version="5.2.0" \
|
||||
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
|
||||
|
||||
SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]
|
||||
|
||||
# copy backup script
|
||||
COPY containers/zammad-postgresql/backup.sh /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/backup.sh
|
@ -1,65 +0,0 @@
|
||||
# note: zammad is currently incompatible to alpine because of:
|
||||
# https://github.com/docker-library/ruby/issues/113
|
||||
FROM ruby:3.0.4-slim AS builder
|
||||
|
||||
ARG BUILD_DATE
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
ENV GIT_BRANCH stable
|
||||
ENV GIT_URL ${PROJECT_URL}.git
|
||||
ENV PROJECT_URL https://github.com/zammad/zammad
|
||||
ENV RAILS_ENV production
|
||||
ENV RAILS_LOG_TO_STDOUT true
|
||||
ENV TAR_GZ_URL ${PROJECT_URL}/archive/${GIT_BRANCH}.tar.gz
|
||||
ENV ZAMMAD_DIR /opt/zammad
|
||||
ENV ZAMMAD_READY_FILE ${ZAMMAD_DIR}/tmp/zammad.ready
|
||||
ENV ZAMMAD_TMP_DIR /tmp/zammad-${GIT_BRANCH}
|
||||
ENV ZAMMAD_USER zammad
|
||||
|
||||
SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]
|
||||
|
||||
# install zammad
|
||||
COPY containers/zammad/setup.sh /tmp
|
||||
RUN chmod +x /tmp/setup.sh; \
|
||||
/tmp/setup.sh builder
|
||||
|
||||
|
||||
FROM ruby:3.0.4-slim
|
||||
|
||||
ARG BUILD_DATE
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
LABEL org.label-schema.build-date="$BUILD_DATE" \
|
||||
org.label-schema.name="Zammad" \
|
||||
org.label-schema.license="AGPL-3.0" \
|
||||
org.label-schema.description="Docker container for Zammad - Data Container" \
|
||||
org.label-schema.url="https://zammad.org" \
|
||||
org.label-schema.vcs-url="https://github.com/zammad/zammad" \
|
||||
org.label-schema.vcs-type="Git" \
|
||||
org.label-schema.vendor="Zammad" \
|
||||
org.label-schema.schema-version="5.2.0" \
|
||||
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
|
||||
|
||||
ENV GIT_BRANCH stable
|
||||
ENV RAILS_ENV production
|
||||
ENV RAILS_LOG_TO_STDOUT true
|
||||
ENV ZAMMAD_DIR /opt/zammad
|
||||
ENV ZAMMAD_READY_FILE ${ZAMMAD_DIR}/tmp/zammad.ready
|
||||
ENV ZAMMAD_TMP_DIR /tmp/zammad-${GIT_BRANCH}
|
||||
ENV ZAMMAD_USER zammad
|
||||
|
||||
COPY containers/zammad/setup.sh /tmp
|
||||
RUN chmod +x /tmp/setup.sh; \
|
||||
/tmp/setup.sh runner
|
||||
|
||||
COPY --from=builder ${ZAMMAD_TMP_DIR} ${ZAMMAD_TMP_DIR}
|
||||
COPY --from=builder /usr/local/bundle /usr/local/bundle
|
||||
|
||||
# docker init
|
||||
COPY containers/zammad/docker-entrypoint.sh /
|
||||
RUN chmod +x /docker-entrypoint.sh
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
|
||||
USER zammad
|
||||
|
||||
WORKDIR ${ZAMMAD_DIR}
|
@ -1,173 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
: "${AUTOWIZARD_JSON:=''}"
|
||||
: "${ELASTICSEARCH_ENABLED:=true}"
|
||||
: "${ELASTICSEARCH_HOST:=zammad-elasticsearch}"
|
||||
: "${ELASTICSEARCH_PORT:=9200}"
|
||||
: "${ELASTICSEARCH_SCHEMA:=http}"
|
||||
: "${ELASTICSEARCH_NAMESPACE:=zammad}"
|
||||
: "${ELASTICSEARCH_REINDEX:=true}"
|
||||
: "${ELASTICSEARCH_SSL_VERIFY:=true}"
|
||||
: "${NGINX_PORT:=8080}"
|
||||
: "${NGINX_SERVER_NAME:=_}"
|
||||
: "${NGINX_SERVER_SCHEME:=\$scheme}"
|
||||
: "${POSTGRESQL_HOST:=zammad-postgresql}"
|
||||
: "${POSTGRESQL_PORT:=5432}"
|
||||
: "${POSTGRESQL_USER:=zammad}"
|
||||
: "${POSTGRESQL_PASS:=zammad}"
|
||||
: "${POSTGRESQL_DB:=zammad_production}"
|
||||
: "${POSTGRESQL_DB_CREATE:=true}"
|
||||
: "${RAILS_TRUSTED_PROXIES:=['127.0.0.1', '::1']}"
|
||||
: "${RSYNC_ADDITIONAL_PARAMS:=--no-perms --no-owner}"
|
||||
: "${ZAMMAD_RAILSSERVER_HOST:=zammad-railsserver}"
|
||||
: "${ZAMMAD_RAILSSERVER_PORT:=3000}"
|
||||
: "${ZAMMAD_WEBSOCKET_HOST:=zammad-websocket}"
|
||||
: "${ZAMMAD_WEBSOCKET_PORT:=6042}"
|
||||
: "${ZAMMAD_WEB_CONCURRENCY:=0}"
|
||||
|
||||
function check_zammad_ready {
|
||||
sleep 15
|
||||
until [ -f "${ZAMMAD_READY_FILE}" ]; do
|
||||
echo "waiting for init container to finish install or update..."
|
||||
sleep 10
|
||||
done
|
||||
}
|
||||
|
||||
# zammad init
|
||||
if [ "$1" = 'zammad-init' ]; then
|
||||
# install / update zammad
|
||||
test -f "${ZAMMAD_READY_FILE}" && rm "${ZAMMAD_READY_FILE}"
|
||||
# shellcheck disable=SC2086
|
||||
rsync -a ${RSYNC_ADDITIONAL_PARAMS} --delete --exclude 'public/assets/images/*' --exclude 'storage/fs/*' "${ZAMMAD_TMP_DIR}/" "${ZAMMAD_DIR}"
|
||||
# shellcheck disable=SC2086
|
||||
rsync -a ${RSYNC_ADDITIONAL_PARAMS} "${ZAMMAD_TMP_DIR}"/public/assets/images/ "${ZAMMAD_DIR}"/public/assets/images
|
||||
|
||||
until (echo > /dev/tcp/"${POSTGRESQL_HOST}"/"${POSTGRESQL_PORT}") &> /dev/null; do
|
||||
echo "zammad railsserver waiting for postgresql server to be ready..."
|
||||
sleep 5
|
||||
done
|
||||
|
||||
cd "${ZAMMAD_DIR}"
|
||||
|
||||
# configure database
|
||||
# https://stackoverflow.com/questions/407523/escape-a-string-for-a-sed-replace-pattern
|
||||
ESCAPED_POSTGRESQL_PASS=$(echo "$POSTGRESQL_PASS" | sed -e 's/[\/&]/\\&/g')
|
||||
sed -e "s#.*adapter:.*# adapter: postgresql#g" -e "s#.*database:.*# database: ${POSTGRESQL_DB}#g" -e "s#.*username:.*# username: ${POSTGRESQL_USER}#g" -e "s#.*password:.*# password: ${ESCAPED_POSTGRESQL_PASS}\\n host: ${POSTGRESQL_HOST}\\n port: ${POSTGRESQL_PORT}#g" < contrib/packager.io/database.yml.pkgr > config/database.yml
|
||||
|
||||
# configure trusted proxies
|
||||
sed -i -e "s#config.action_dispatch.trusted_proxies =.*#config.action_dispatch.trusted_proxies = ${RAILS_TRUSTED_PROXIES}#" config/environments/production.rb
|
||||
|
||||
# check if database exists / update to new version
|
||||
echo "initialising / updating database..."
|
||||
if ! (bundle exec rails r 'puts User.any?' 2> /dev/null | grep -q true); then
|
||||
if [ "${POSTGRESQL_DB_CREATE}" == "true" ]; then
|
||||
bundle exec rake db:create
|
||||
fi
|
||||
bundle exec rake db:migrate
|
||||
bundle exec rake db:seed
|
||||
|
||||
# create autowizard.json on first install
|
||||
if base64 -d <<< ${AUTOWIZARD_JSON} &>> /dev/null; then
|
||||
echo "Saving autowizard json payload..."
|
||||
base64 -d <<< "${AUTOWIZARD_JSON}" > auto_wizard.json
|
||||
fi
|
||||
else
|
||||
bundle exec rails r "Cache.clear"
|
||||
bundle exec rake db:migrate
|
||||
fi
|
||||
|
||||
# es config
|
||||
echo "changing settings..."
|
||||
if [ "${ELASTICSEARCH_ENABLED}" == "false" ]; then
|
||||
bundle exec rails r "Setting.set('es_url', '')"
|
||||
else
|
||||
bundle exec rails r "Setting.set('es_url', '${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}')"
|
||||
|
||||
bundle exec rails r "Setting.set('es_index', '${ELASTICSEARCH_NAMESPACE}')"
|
||||
|
||||
if [ -n "${ELASTICSEARCH_USER}" ] && [ -n "${ELASTICSEARCH_PASS}" ]; then
|
||||
bundle exec rails r "Setting.set('es_user', \"${ELASTICSEARCH_USER}\")"
|
||||
bundle exec rails r "Setting.set('es_password', \"${ELASTICSEARCH_PASS}\")"
|
||||
fi
|
||||
|
||||
until (echo > /dev/tcp/${ELASTICSEARCH_HOST}/${ELASTICSEARCH_PORT}) &> /dev/null; do
|
||||
echo "zammad railsserver waiting for elasticsearch server to be ready..."
|
||||
sleep 5
|
||||
done
|
||||
|
||||
if [ "${ELASTICSEARCH_SSL_VERIFY}" == "false" ]; then
|
||||
SSL_SKIP_VERIFY="-k"
|
||||
else
|
||||
SSL_SKIP_VERIFY=""
|
||||
fi
|
||||
|
||||
if [ "${ELASTICSEARCH_REINDEX}" == "true" ]; then
|
||||
if ! curl -s "${SSL_SKIP_VERIFY}" "${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}/_cat/indices" | grep -q zammad; then
|
||||
echo "rebuilding es searchindex..."
|
||||
bundle exec rake zammad:searchindex:rebuild
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# create install ready file
|
||||
echo 'zammad-init' > "${ZAMMAD_READY_FILE}"
|
||||
fi
|
||||
|
||||
|
||||
# zammad nginx
|
||||
if [ "$1" = 'zammad-nginx' ]; then
|
||||
check_zammad_ready
|
||||
|
||||
# configure nginx
|
||||
sed -e "s#\(listen\)\(.*\)80#\1\2${NGINX_PORT}#g" \
|
||||
-e "s#proxy_set_header X-Forwarded-Proto .*;#proxy_set_header X-Forwarded-Proto ${NGINX_SERVER_SCHEME};#g" \
|
||||
-e "s#server .*:3000#server ${ZAMMAD_RAILSSERVER_HOST}:${ZAMMAD_RAILSSERVER_PORT}#g" \
|
||||
-e "s#server .*:6042#server ${ZAMMAD_WEBSOCKET_HOST}:${ZAMMAD_WEBSOCKET_PORT}#g" \
|
||||
-e "s#server_name .*#server_name ${NGINX_SERVER_NAME};#g" \
|
||||
-e 's#/var/log/nginx/zammad.\(access\|error\).log#/dev/stdout#g' < contrib/nginx/zammad.conf > /etc/nginx/sites-enabled/default
|
||||
|
||||
echo "starting nginx..."
|
||||
|
||||
exec /usr/sbin/nginx -g 'daemon off;'
|
||||
fi
|
||||
|
||||
|
||||
# zammad-railsserver
|
||||
if [ "$1" = 'zammad-railsserver' ]; then
|
||||
test -f /opt/zammad/tmp/pids/server.pid && rm /opt/zammad/tmp/pids/server.pid
|
||||
|
||||
check_zammad_ready
|
||||
|
||||
cd "${ZAMMAD_DIR}"
|
||||
|
||||
echo "starting railsserver... with WEB_CONCURRENCY=${ZAMMAD_WEB_CONCURRENCY}"
|
||||
|
||||
#shellcheck disable=SC2101
|
||||
exec bundle exec puma -b tcp://[::]:"${ZAMMAD_RAILSSERVER_PORT}" -w "${ZAMMAD_WEB_CONCURRENCY}" -e "${RAILS_ENV}"
|
||||
fi
|
||||
|
||||
|
||||
# zammad-scheduler
|
||||
if [ "$1" = 'zammad-scheduler' ]; then
|
||||
check_zammad_ready
|
||||
|
||||
cd "${ZAMMAD_DIR}"
|
||||
|
||||
echo "starting background services..."
|
||||
|
||||
exec bundle exec script/background-worker.rb start
|
||||
fi
|
||||
|
||||
|
||||
# zammad-websocket
|
||||
if [ "$1" = 'zammad-websocket' ]; then
|
||||
check_zammad_ready
|
||||
|
||||
cd "${ZAMMAD_DIR}"
|
||||
|
||||
echo "starting websocket server..."
|
||||
|
||||
exec bundle exec script/websocket-server.rb -b 0.0.0.0 -p "${ZAMMAD_WEBSOCKET_PORT}" start
|
||||
fi
|
@ -1,59 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# install dependencies
|
||||
if [ "$1" = 'builder' ]; then
|
||||
PACKAGES="build-essential curl git libimlib2-dev libpq-dev shared-mime-info"
|
||||
elif [ "$1" = 'runner' ]; then
|
||||
PACKAGES="curl libimlib2 libpq5 nginx rsync"
|
||||
fi
|
||||
|
||||
apt-get update
|
||||
apt-get upgrade -y
|
||||
# shellcheck disable=SC2086
|
||||
apt-get install -y --no-install-recommends ${PACKAGES}
|
||||
|
||||
if [ "$1" = 'builder' ]; then
|
||||
# Install Node.js 16 repository from Nodesource
|
||||
apt-get --no-install-recommends -y install gnupg
|
||||
KEYRING=/usr/share/keyrings/nodesource.gpg
|
||||
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee "$KEYRING" >/dev/null
|
||||
cat - > /etc/apt/sources.list.d/nodesource.list <<NODESOURCE_LIST
|
||||
deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x buster main
|
||||
NODESOURCE_LIST
|
||||
|
||||
apt-get update
|
||||
apt-get --no-install-recommends -y install nodejs
|
||||
npm -g install yarn
|
||||
fi
|
||||
|
||||
# Clean-up
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# install zammad
|
||||
groupadd -g 1000 "${ZAMMAD_USER}"
|
||||
useradd -M -d "${ZAMMAD_DIR}" -s /bin/bash -u 1000 -g 1000 "${ZAMMAD_USER}"
|
||||
|
||||
if [ "$1" = 'builder' ]; then
|
||||
cd "$(dirname "${ZAMMAD_TMP_DIR}")"
|
||||
curl -s -J -L -O "${TAR_GZ_URL}"
|
||||
tar -xzf zammad-"${GIT_BRANCH}".tar.gz
|
||||
rm zammad-"${GIT_BRANCH}".tar.gz
|
||||
cd "${ZAMMAD_TMP_DIR}"
|
||||
bundle config set without 'test development mysql'
|
||||
bundle install
|
||||
sed -e 's#.*adapter: postgresql# adapter: nulldb#g' -e 's#.*username:.*# username: postgres#g' -e 's#.*password:.*# password: \n host: zammad-postgresql\n#g' < contrib/packager.io/database.yml.pkgr > config/database.yml
|
||||
sed -i "/require 'rails\/all'/a require\ 'nulldb'" config/application.rb
|
||||
touch db/schema.rb
|
||||
bundle exec rake assets:precompile
|
||||
rm -r tmp/cache
|
||||
script/build/cleanup.sh
|
||||
chown -R "${ZAMMAD_USER}":"${ZAMMAD_USER}" "${ZAMMAD_TMP_DIR}"
|
||||
fi
|
||||
|
||||
# set nginx file permissions and settings
|
||||
if [ "$1" = 'runner' ]; then
|
||||
sed -i -e "s#user www-data;##g" -e 's#/var/log/nginx/\(access\|error\).log#/dev/stdout#g' -e 's#pid /run/nginx.pid;#pid /tmp/nginx.pid;#g' /etc/nginx/nginx.conf
|
||||
mkdir -p "${ZAMMAD_DIR}" /var/log/nginx
|
||||
chown -R "${ZAMMAD_USER}":"${ZAMMAD_USER}" /etc/nginx "${ZAMMAD_DIR}" /var/lib/nginx /var/log/nginx
|
||||
fi
|
@ -3,21 +3,12 @@ version: '3'
|
||||
|
||||
services:
|
||||
|
||||
zammad-backup:
|
||||
image: zammad-postgresql-local
|
||||
|
||||
zammad-elasticsearch:
|
||||
image: zammad-elasticsearch-local
|
||||
|
||||
zammad-init:
|
||||
image: zammad-local
|
||||
|
||||
zammad-nginx:
|
||||
image: zammad-local
|
||||
|
||||
zammad-postgresql:
|
||||
image: zammad-postgresql-local
|
||||
|
||||
zammad-railsserver:
|
||||
image: zammad-local
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
version: '3'
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
|
||||
@ -10,23 +10,24 @@ services:
|
||||
- zammad-postgresql
|
||||
entrypoint: /usr/local/bin/backup.sh
|
||||
environment:
|
||||
- BACKUP_SLEEP=86400
|
||||
- BACKUP_TIME=03:00
|
||||
- HOLD_DAYS=10
|
||||
- POSTGRESQL_DB=${POSTGRES_DB}
|
||||
- POSTGRESQL_USER=${POSTGRES_USER}
|
||||
- POSTGRESQL_PASSWORD=${POSTGRES_PASS}
|
||||
image: ${IMAGE_REPO}:zammad-postgresql${VERSION}
|
||||
- TZ=Europe/Berlin
|
||||
image: postgres:${POSTGRES_VERSION}
|
||||
restart: ${RESTART}
|
||||
volumes:
|
||||
- zammad-backup:/var/tmp/zammad
|
||||
- zammad-data:/opt/zammad
|
||||
- zammad-var:/opt/zammad/var:ro
|
||||
- ./scripts/backup.sh:/usr/local/bin/backup.sh:ro
|
||||
|
||||
zammad-elasticsearch:
|
||||
environment:
|
||||
- discovery.type=single-node
|
||||
image: ${IMAGE_REPO}:zammad-elasticsearch${VERSION}
|
||||
image: bitnami/elasticsearch:${ELASTICSEARCH_VERSION}
|
||||
restart: ${RESTART}
|
||||
volumes:
|
||||
- elasticsearch-data:/usr/share/elasticsearch/data
|
||||
- elasticsearch-data:/bitnami/elasticsearch/data
|
||||
|
||||
zammad-init:
|
||||
command: ["zammad-init"]
|
||||
@ -34,17 +35,17 @@ services:
|
||||
- zammad-postgresql
|
||||
environment:
|
||||
- MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
|
||||
- POSTGRESQL_USER=${POSTGRES_USER}
|
||||
- POSTGRESQL_PASS=${POSTGRES_PASS}
|
||||
- REDIS_URL=${REDIS_URL}
|
||||
image: ${IMAGE_REPO}:zammad${VERSION}
|
||||
image: ${IMAGE_REPO}:${VERSION}
|
||||
restart: on-failure
|
||||
user: 0:0
|
||||
volumes:
|
||||
- zammad-data:/opt/zammad
|
||||
- zammad-config-nginx:/etc/nginx/sites-enabled
|
||||
- zammad-var:/opt/zammad/var
|
||||
|
||||
zammad-memcached:
|
||||
command: memcached -m 256M
|
||||
image: memcached:1.6.10-alpine
|
||||
image: memcached:${MEMCACHE_VERSION}
|
||||
restart: ${RESTART}
|
||||
|
||||
zammad-nginx:
|
||||
@ -53,16 +54,18 @@ services:
|
||||
- "8080"
|
||||
depends_on:
|
||||
- zammad-railsserver
|
||||
image: ${IMAGE_REPO}:zammad${VERSION}
|
||||
image: ${IMAGE_REPO}:${VERSION}
|
||||
restart: ${RESTART}
|
||||
volumes:
|
||||
- zammad-data:/opt/zammad
|
||||
- zammad-config-nginx:/etc/nginx/sites-enabled:ro
|
||||
- zammad-var:/opt/zammad/var:ro
|
||||
|
||||
zammad-postgresql:
|
||||
environment:
|
||||
- POSTGRES_DB=${POSTGRES_DB}
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASS}
|
||||
image: ${IMAGE_REPO}:zammad-postgresql${VERSION}
|
||||
image: postgres:${POSTGRES_VERSION}
|
||||
restart: ${RESTART}
|
||||
volumes:
|
||||
- postgresql-data:/var/lib/postgresql/data
|
||||
@ -76,14 +79,16 @@ services:
|
||||
environment:
|
||||
- MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
|
||||
- REDIS_URL=${REDIS_URL}
|
||||
image: ${IMAGE_REPO}:zammad${VERSION}
|
||||
image: ${IMAGE_REPO}:${VERSION}
|
||||
restart: ${RESTART}
|
||||
volumes:
|
||||
- zammad-data:/opt/zammad
|
||||
- zammad-var:/opt/zammad/var
|
||||
|
||||
zammad-redis:
|
||||
image: redis:6.2.5-alpine
|
||||
image: redis:${REDIS_VERSION}
|
||||
restart: ${RESTART}
|
||||
volumes:
|
||||
- redis-data:/data
|
||||
|
||||
zammad-scheduler:
|
||||
command: ["zammad-scheduler"]
|
||||
@ -94,10 +99,10 @@ services:
|
||||
environment:
|
||||
- MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
|
||||
- REDIS_URL=${REDIS_URL}
|
||||
image: ${IMAGE_REPO}:zammad${VERSION}
|
||||
image: ${IMAGE_REPO}:${VERSION}
|
||||
restart: ${RESTART}
|
||||
volumes:
|
||||
- zammad-data:/opt/zammad
|
||||
- zammad-var:/opt/zammad/var
|
||||
|
||||
zammad-websocket:
|
||||
command: ["zammad-websocket"]
|
||||
@ -108,17 +113,21 @@ services:
|
||||
environment:
|
||||
- MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
|
||||
- REDIS_URL=${REDIS_URL}
|
||||
image: ${IMAGE_REPO}:zammad${VERSION}
|
||||
image: ${IMAGE_REPO}:${VERSION}
|
||||
restart: ${RESTART}
|
||||
volumes:
|
||||
- zammad-data:/opt/zammad
|
||||
- zammad-var:/opt/zammad/var
|
||||
|
||||
volumes:
|
||||
elasticsearch-data:
|
||||
driver: local
|
||||
postgresql-data:
|
||||
driver: local
|
||||
redis-data:
|
||||
driver: local
|
||||
zammad-backup:
|
||||
driver: local
|
||||
zammad-data:
|
||||
zammad-config-nginx:
|
||||
driver: local
|
||||
zammad-var:
|
||||
driver: local
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
: "${ZAMMAD_DIR:=/opt/zammad}"
|
||||
: "${ZAMMAD_DIR:=/opt/zammad/var}"
|
||||
: "${BACKUP_DIR:=/var/tmp/zammad}"
|
||||
: "${ZAMMAD_RAILSSERVER_HOST:=zammad-railsserver}"
|
||||
: "${ZAMMAD_RAILSSERVER_PORT:=3000}"
|
||||
@ -11,7 +11,7 @@ set -e
|
||||
: "${POSTGRESQL_DB:=zammad_production}"
|
||||
|
||||
function check_railsserver_available {
|
||||
until (echo > /dev/tcp/${ZAMMAD_RAILSSERVER_HOST}/${ZAMMAD_RAILSSERVER_PORT}) &> /dev/null; do
|
||||
until (echo > "/dev/tcp/$ZAMMAD_RAILSSERVER_HOST/$ZAMMAD_RAILSSERVER_PORT") &> /dev/null; do
|
||||
echo "waiting for railsserver to be ready..."
|
||||
sleep 60
|
||||
done
|
||||
@ -34,6 +34,8 @@ function zammad_backup {
|
||||
|
||||
#db backup
|
||||
pg_dump --dbname=postgresql://"${POSTGRESQL_USER}:${POSTGRESQL_PASSWORD}@${POSTGRESQL_HOST}:${POSTGRESQL_PORT}/${POSTGRESQL_DB}" | gzip > "${BACKUP_DIR}"/"${TIMESTAMP}"_zammad_db.psql.gz
|
||||
|
||||
echo "backup finished :)"
|
||||
}
|
||||
|
||||
if [ "$1" = 'zammad-backup' ]; then
|
||||
@ -41,10 +43,15 @@ if [ "$1" = 'zammad-backup' ]; then
|
||||
check_railsserver_available
|
||||
|
||||
while true; do
|
||||
NOW_TIMESTAMP=$(date +%s)
|
||||
TOMORROW_DATE=$(date -d@"$((NOW_TIMESTAMP + 24*60*60))" +%Y-%m-%d)
|
||||
|
||||
zammad_backup
|
||||
|
||||
# wait until next backup
|
||||
sleep "${BACKUP_SLEEP}"
|
||||
NEXT_TIMESTAMP=$(date -d "$TOMORROW_DATE $BACKUP_TIME" +%s)
|
||||
NOW_TIMESTAMP=$(date +%s)
|
||||
|
||||
sleep $((NEXT_TIMESTAMP - NOW_TIMESTAMP))
|
||||
done
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user