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.schema-version="1.2" \
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up" 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 RUN rm /etc/nginx/conf.d/default.conf

View File

@ -2,12 +2,12 @@
# this is the nginx config for zammad # this is the nginx config for zammad
# #
upstream zammad { upstream zammad-railsserver {
server zammad:3000; server zammad-railsserver:3000;
} }
upstream zammad-websocket { upstream zammad-websocket {
server zammad:6042; server zammad-websocket:6042;
} }
server { server {
@ -42,7 +42,7 @@ server {
proxy_set_header CLIENT_IP $remote_addr; proxy_set_header CLIENT_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 180; proxy_read_timeout 180;
proxy_pass http://zammad; proxy_pass http://zammad-railsserver;
gzip on; gzip on;
gzip_types text/plain text/xml text/css image/svg+xml application/javascript application/x-javascript application/json application/xml; 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 #!/bin/bash
if [ "$1" = 'zammad' ]; then if [ "$1" = 'zammad-railsserver' ]; then
cd ${ZAMMAD_DIR} cd ${ZAMMAD_DIR}
bundle exec rake db:migrate &> /dev/null bundle exec rake db:migrate &> /dev/null
@ -14,15 +14,12 @@ if [ "$1" = 'zammad' ]; then
bundle exec rake searchindex:rebuild bundle exec rake searchindex:rebuild
fi fi
# delete logs & pids # delete logs
find ${ZAMMAD_DIR}/log -iname *.log -exec rm {} \; find ${ZAMMAD_DIR}/log -iname *.log -exec rm {} \;
find ${ZAMMAD_DIR}/tmp/pids -iname *.pid -exec rm {} \;
# run zammad # run zammad
echo "starting zammad..." echo "starting zammad..."
echo "zammad will be accessable on http://localhost in some seconds" 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 if [ "${RAILS_SERVER}" == "puma" ]; then
bundle exec puma -b tcp://0.0.0.0:3000 -e ${RAILS_ENV} 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" \ LABEL org.label-schema.build-date="$BUILD_DATE" \
org.label-schema.name="Zammad" \ org.label-schema.name="Zammad" \
org.label-schema.license="AGPL-3.0" \ 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.url="https://zammad.org" \
org.label-schema.vcs-url="https://github.com/zammad/zammad" \ org.label-schema.vcs-url="https://github.com/zammad/zammad" \
org.label-schema.vcs-type="Git" \ 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.schema-version="1.2" \
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up" org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
# Expose ports
EXPOSE 3000
EXPOSE 6042
# install dependencies # install dependencies
RUN apt-get update && apt-get install -y build-essential git-core libpq5 libpq-dev RUN apt-get update && apt-get install -y build-essential git-core libpq5 libpq-dev
# install zammad # 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 RUN chmod +x /tmp/install-zammad.sh;/bin/bash -l -c /tmp/install-zammad.sh
# cleanup # cleanup
@ -35,9 +31,3 @@ RUN apt-get remove --purge -y git-core build-essential bzip2 libffi-dev libgdbm3
apt-get autoremove -y && \ apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/* 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 #!/bin/bash
set -e set -ex
echo "installing zammad..."
# create zammad user # create zammad user
useradd -M -d "${ZAMMAD_DIR}" -s /bin/bash zammad useradd -M -d "${ZAMMAD_DIR}" -s /bin/bash zammad

View File

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

View File

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

View File

@ -8,6 +8,7 @@
for DOCKER_IMAGE in ${DOCKER_IMAGES}; do for DOCKER_IMAGE in ${DOCKER_IMAGES}; do
echo "Build Zammad Docker image ${DOCKER_IMAGE} for DockerHubs ${DOCKER_REPO}:${DOCKER_IMAGE} repo" 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 done

View File

@ -3,4 +3,4 @@
# build hooks config # 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