split up zammad processes in own containers

This commit is contained in:
André Bauer 2017-01-12 14:14:25 +01:00
parent 04031b2d22
commit 66d31548f4
17 changed files with 215 additions and 61 deletions

View File

@ -13,7 +13,7 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \
org.label-schema.schema-version="1.2" \
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
ADD nginx-zammad.conf /etc/nginx/conf.d/zammad.conf
ADD containers/nginx/nginx-zammad.conf /etc/nginx/conf.d/zammad.conf
RUN rm /etc/nginx/conf.d/default.conf

View File

@ -2,12 +2,12 @@
# this is the nginx config for zammad
#
upstream zammad {
server zammad:3000;
upstream zammad-railsserver {
server zammad-railsserver:3000;
}
upstream zammad-websocket {
server zammad:6042;
server zammad-websocket:6042;
}
server {
@ -42,7 +42,7 @@ server {
proxy_set_header CLIENT_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 180;
proxy_pass http://zammad;
proxy_pass http://zammad-railsserver;
gzip on;
gzip_types text/plain text/xml text/css image/svg+xml application/javascript application/x-javascript application/json application/xml;

View File

@ -0,0 +1,31 @@
FROM zammad/zammad-docker-compose:zammad
MAINTAINER Zammad <info@zammad.org>
ARG BUILD_DATE
ENV ZAMMAD_DIR /home/zammad
ENV RAILS_ENV production
ENV RAILS_SERVER puma
ENV GIT_URL https://github.com/zammad/zammad.git
ENV GIT_BRANCH develop
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 - Rails server" \
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="1.2" \
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
# Expose ports
EXPOSE 3000
# docker init
USER root
COPY containers/zammad-railsserver/docker-entrypoint.sh /
RUN chown zammad:zammad /docker-entrypoint.sh;chmod +x /docker-entrypoint.sh
USER zammad
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["zammad-railsserver"]

View File

@ -1,6 +1,6 @@
#!/bin/bash
if [ "$1" = 'zammad' ]; then
if [ "$1" = 'zammad-railsserver' ]; then
cd ${ZAMMAD_DIR}
bundle exec rake db:migrate &> /dev/null
@ -14,15 +14,12 @@ if [ "$1" = 'zammad' ]; then
bundle exec rake searchindex:rebuild
fi
# delete logs & pids
# delete logs
find ${ZAMMAD_DIR}/log -iname *.log -exec rm {} \;
find ${ZAMMAD_DIR}/tmp/pids -iname *.pid -exec rm {} \;
# run zammad
echo "starting zammad..."
echo "zammad will be accessable on http://localhost in some seconds"
bundle exec script/websocket-server.rb -b 0.0.0.0 start &
bundle exec script/scheduler.rb start &
if [ "${RAILS_SERVER}" == "puma" ]; then
bundle exec puma -b tcp://0.0.0.0:3000 -e ${RAILS_ENV}

View File

@ -0,0 +1,28 @@
FROM zammad/zammad-docker-compose:zammad
MAINTAINER Zammad <info@zammad.org>
ARG BUILD_DATE
ENV ZAMMAD_DIR /home/zammad
ENV RAILS_ENV production
ENV RAILS_SERVER puma
ENV GIT_URL https://github.com/zammad/zammad.git
ENV GIT_BRANCH develop
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 - Scheduler" \
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="1.2" \
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
# docker init
USER root
COPY containers/zammad-scheduler/docker-entrypoint.sh /
RUN chown zammad:zammad /docker-entrypoint.sh;chmod +x /docker-entrypoint.sh
USER zammad
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["zammad-scheduler"]

View File

@ -0,0 +1,9 @@
#!/bin/bash
if [ "$1" = 'zammad-scheduler' ]; then
# start scheduler
cd ${ZAMMAD_DIR}
bundle exec script/scheduler.rb run
fi

View File

@ -0,0 +1,31 @@
FROM zammad/zammad-docker-compose:zammad
MAINTAINER Zammad <info@zammad.org>
ARG BUILD_DATE
ENV ZAMMAD_DIR /home/zammad
ENV RAILS_ENV production
ENV RAILS_SERVER puma
ENV GIT_URL https://github.com/zammad/zammad.git
ENV GIT_BRANCH develop
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 - Wenbscocket server" \
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="1.2" \
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
# Expose ports
EXPOSE 6042
# docker init
USER root
COPY containers/zammad-websocket/docker-entrypoint.sh /
RUN chown zammad:zammad /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh
USER zammad
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["zammad-websocket"]

View File

@ -0,0 +1,8 @@
#!/bin/bash
if [ "$1" = 'zammad-websocket' ]; then
cd ${ZAMMAD_DIR}
bundle exec script/websocket-server.rb -b 0.0.0.0 start
fi

View File

@ -11,7 +11,7 @@ ENV GIT_BRANCH develop
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" \
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" \
@ -19,15 +19,11 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \
org.label-schema.schema-version="1.2" \
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
# Expose ports
EXPOSE 3000
EXPOSE 6042
# install dependencies
RUN apt-get update && apt-get install -y build-essential git-core libpq5 libpq-dev
# install zammad
COPY install-zammad.sh /tmp
COPY containers/zammad/install-zammad.sh /tmp
RUN chmod +x /tmp/install-zammad.sh;/bin/bash -l -c /tmp/install-zammad.sh
# cleanup
@ -35,9 +31,3 @@ RUN apt-get remove --purge -y git-core build-essential bzip2 libffi-dev libgdbm3
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
# docker init
COPY docker-entrypoint.sh /
RUN chown zammad:zammad /docker-entrypoint.sh;chmod +x /docker-entrypoint.sh
USER zammad
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["zammad"]

View File

@ -1,8 +1,6 @@
#!/bin/bash
set -e
echo "installing zammad..."
set -ex
# create zammad user
useradd -M -d "${ZAMMAD_DIR}" -s /bin/bash zammad

View File

@ -1,41 +1,81 @@
version: '2'
services:
elasticsearch:
build:
context: .
dockerfile: Dockerfile.elasticsearch
dockerfile: containers/elasticsearch/Dockerfile
restart: always
nginx:
build:
context: .
dockerfile: Dockerfile.nginx
dockerfile: containers/nginx/Dockerfile
depends_on:
- zammad
links:
- zammad
- zammad-railsserver
- zammad-websocket
ports:
- "80:80"
restart: always
volumes:
- data-zammad:/home/zammad
postgresql:
build:
context: .
dockerfile: Dockerfile.postgresql
dockerfile: containers/postgresql/Dockerfile
restart: always
zammad:
build:
context: .
dockerfile: Dockerfile.zammad
depends_on:
- postgresql
- elasticsearch
links:
- postgresql
- elasticsearch
restart: always
dockerfile: containers/zammad/Dockerfile
restart: on-failure
volumes:
- data-zammad:/home/zammad
zammad-railsserver:
build:
context: .
dockerfile: containers/zammad-railsserver/Dockerfile
depends_on:
- elasticsearch
- postgresql
- zammad
links:
- elasticsearch
- postgresql
restart: always
zammad-scheduler:
build:
context: .
dockerfile: containers/zammad-scheduler/Dockerfile
depends_on:
- elasticsearch
- postgresql
- zammad
links:
- elasticsearch
- postgresql
restart: always
zammad-websocket:
build:
context: .
dockerfile: containers/zammad-websocket/Dockerfile
depends_on:
- elasticsearch
- postgresql
- zammad
links:
- elasticsearch
- postgresql
restart: always
volumes:
data-zammad:
driver: local

View File

@ -1,33 +1,68 @@
version: '2'
services:
elasticsearch:
image: zammad/zammad-docker-compose:elasticsearch
restart: always
nginx:
depends_on:
- zammad
image: zammad/zammad-docker-compose:nginx
links:
- zammad
- zammad-railsserver
- zammad-websocket
ports:
- "80:80"
restart: always
volumes:
- data-zammad:/home/zammad
postgresql:
image: zammad/zammad-docker-compose:postgresql
restart: always
zammad:
image: zammad/zammad-docker-compose:zammad
links:
- postgresql
- elasticsearch
depends_on:
- postgresql
- elasticsearch
restart: always
restart: on-failure
volumes:
- data-zammad:/home/zammad
zammad-railsserver:
image: zammad/zammad-docker-compose:zammad-railsserver
links:
- elasticsearch
- postgresql
- zammad
depends_on:
- elasticsearch
- postgresql
- zammad
restart: always
zammad-scheduler:
image: zammad/zammad-docker-compose:zammad-scheduler
links:
- elasticsearch
- postgresql
- zammad
depends_on:
- elasticsearch
- postgresql
- zammad
restart: always
zammad-websocket:
image: zammad/zammad-docker-compose:zammad-websocket
links:
- postgresql
- zammad
depends_on:
- postgresql
- zammad
restart: always
volumes:
data-zammad:
driver: local

View File

@ -8,6 +8,7 @@
for DOCKER_IMAGE in ${DOCKER_IMAGES}; do
echo "Build Zammad Docker image ${DOCKER_IMAGE} for DockerHubs ${DOCKER_REPO}:${DOCKER_IMAGE} repo"
docker build --no-cache --build-arg BUILD_DATE=$(date -u +”%Y-%m-%dT%H:%M:%SZ”) -t ${DOCKER_REPO}:${DOCKER_IMAGE} -f Dockerfile.${DOCKER_IMAGE} .
docker build --no-cache --build-arg BUILD_DATE=$(date -u +”%Y-%m-%dT%H:%M:%SZ”) -t ${DOCKER_REPO}:${DOCKER_IMAGE} -f containers/${DOCKER_IMAGE}/Dockerfile .
docker push ${DOCKER_REPO}:${DOCKER_IMAGE}
done

View File

@ -3,4 +3,4 @@
# build hooks config
#
DOCKER_IMAGES="elasticsearch nginx postgresql zammad"
DOCKER_IMAGES="elasticsearch nginx postgresql zammad zammad-railsserver zammad-scheduler zammad-websocket"

View File

@ -1,14 +0,0 @@
#!/bin/bash
#
# build hook for dockerhubs autobuild feature
#
. "hooks/config"
for DOCKER_IMAGE in ${DOCKER_IMAGES}; do
echo "Push Zammad Docker image ${DOCKER_IMAGE} to DockerHubs ${DOCKER_REPO}:${DOCKER_IMAGE} repo"
docker push ${DOCKER_REPO}:${DOCKER_IMAGE}
done