From 9d4dad8de5398d8b6f5baf53169b60c93139996b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bauer?= Date: Mon, 2 Oct 2017 23:41:16 +0200 Subject: [PATCH] use only one zammad image for all zammad services- fixes #45 --- containers/zammad-backup/Dockerfile | 11 +++--- containers/zammad-railsserver/Dockerfile | 23 ------------- containers/zammad-scheduler/Dockerfile | 20 ----------- .../zammad-scheduler/docker-entrypoint.sh | 15 -------- containers/zammad-websocket/Dockerfile | 23 ------------- .../zammad-websocket/docker-entrypoint.sh | 14 -------- containers/zammad/Dockerfile | 5 +++ .../docker-entrypoint.sh | 34 +++++++++++++++++-- docker-compose-build.yml | 24 +++++-------- docker-compose.yml | 33 ++++++------------ hooks/config | 2 +- rancher-compose.yml | 4 --- 12 files changed, 63 insertions(+), 145 deletions(-) delete mode 100644 containers/zammad-railsserver/Dockerfile delete mode 100644 containers/zammad-scheduler/Dockerfile delete mode 100644 containers/zammad-scheduler/docker-entrypoint.sh delete mode 100644 containers/zammad-websocket/Dockerfile delete mode 100644 containers/zammad-websocket/docker-entrypoint.sh rename containers/{zammad-railsserver => zammad}/docker-entrypoint.sh (60%) diff --git a/containers/zammad-backup/Dockerfile b/containers/zammad-backup/Dockerfile index 2329663..f87366f 100644 --- a/containers/zammad-backup/Dockerfile +++ b/containers/zammad-backup/Dockerfile @@ -1,4 +1,4 @@ -FROM zammad/zammad-docker-compose:zammad +FROM debian MAINTAINER Zammad ARG BUILD_DATE @@ -17,10 +17,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" -RUN wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | apt-key add - \ - && echo "deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main" >> /etc/apt/sources.list.d/postgres.list \ - && apt-get update;apt-get -y install postgresql-client \ - && rm -rf /var/lib/apt/lists/* +RUN apt-get update;apt-get -y wget gnupg2 \ + && wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | apt-key add - \ + && echo "deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main" >> /etc/apt/sources.list.d/postgres.list \ + && apt-get update;apt-get -y install postgresql-client \ + && rm -rf /var/lib/apt/lists/* # create entrypoint COPY containers/zammad-backup/docker-entrypoint.sh / diff --git a/containers/zammad-railsserver/Dockerfile b/containers/zammad-railsserver/Dockerfile deleted file mode 100644 index ae4db6c..0000000 --- a/containers/zammad-railsserver/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM zammad/zammad-docker-compose:zammad -MAINTAINER Zammad -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 - 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 -COPY containers/zammad-railsserver/docker-entrypoint.sh / -RUN chown ${ZAMMAD_USER}:${ZAMMAD_USER} /docker-entrypoint.sh;chmod +x /docker-entrypoint.sh -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["zammad-railsserver"] diff --git a/containers/zammad-scheduler/Dockerfile b/containers/zammad-scheduler/Dockerfile deleted file mode 100644 index 1cb299e..0000000 --- a/containers/zammad-scheduler/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM zammad/zammad-docker-compose:zammad -MAINTAINER Zammad -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 - 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 -COPY containers/zammad-scheduler/docker-entrypoint.sh / -RUN chown ${ZAMMAD_USER}:${ZAMMAD_USER} /docker-entrypoint.sh;chmod +x /docker-entrypoint.sh -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["zammad-scheduler"] diff --git a/containers/zammad-scheduler/docker-entrypoint.sh b/containers/zammad-scheduler/docker-entrypoint.sh deleted file mode 100644 index a1702ae..0000000 --- a/containers/zammad-scheduler/docker-entrypoint.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -if [ "$1" = 'zammad-scheduler' ]; then - # wait for zammad process coming up - until (echo > /dev/tcp/zammad-railsserver/3000) &> /dev/null; do - echo "scheduler waiting for zammads railsserver to be ready..." - sleep 2 - done - - echo "scheduler can access raillsserver now..." - - # start scheduler - cd ${ZAMMAD_DIR} - exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec script/scheduler.rb run -fi diff --git a/containers/zammad-websocket/Dockerfile b/containers/zammad-websocket/Dockerfile deleted file mode 100644 index 2adbc6a..0000000 --- a/containers/zammad-websocket/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM zammad/zammad-docker-compose:zammad -MAINTAINER Zammad -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 - Websocket 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 -COPY containers/zammad-websocket/docker-entrypoint.sh / -RUN chown ${ZAMMAD_USER}:${ZAMMAD_USER} /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["zammad-websocket"] diff --git a/containers/zammad-websocket/docker-entrypoint.sh b/containers/zammad-websocket/docker-entrypoint.sh deleted file mode 100644 index 711b8b7..0000000 --- a/containers/zammad-websocket/docker-entrypoint.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -if [ "$1" = 'zammad-websocket' ]; then - # wait for zammad process coming up - until (echo > /dev/tcp/zammad-railsserver/3000) &> /dev/null; do - echo "websocket server waiting for zammads railsserver to be ready..." - sleep 5 - done - - echo "websocket server can access raillsserver now..." - - cd ${ZAMMAD_DIR} - exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec script/websocket-server.rb -b 0.0.0.0 start -fi diff --git a/containers/zammad/Dockerfile b/containers/zammad/Dockerfile index b99c53c..883d196 100644 --- a/containers/zammad/Dockerfile +++ b/containers/zammad/Dockerfile @@ -47,4 +47,9 @@ RUN BUILD_DEPENDENCIES="git build-essential libffi-dev libpq5 libpq-dev rsync" \ && rm -r tmp/cache \ && chown -R ${ZAMMAD_USER}:${ZAMMAD_USER} ${ZAMMAD_TMP_DIR} +# docker init +COPY containers/zammad/docker-entrypoint.sh / +RUN chown ${ZAMMAD_USER}:${ZAMMAD_USER} /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh +ENTRYPOINT ["/docker-entrypoint.sh"] + WORKDIR ${ZAMMAD_DIR} diff --git a/containers/zammad-railsserver/docker-entrypoint.sh b/containers/zammad/docker-entrypoint.sh similarity index 60% rename from containers/zammad-railsserver/docker-entrypoint.sh rename to containers/zammad/docker-entrypoint.sh index a3c5940..4b67e0e 100644 --- a/containers/zammad-railsserver/docker-entrypoint.sh +++ b/containers/zammad/docker-entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash +# zammad-railsserver if [ "$1" = 'zammad-railsserver' ]; then - # wait for postgres process coming up on zammad-postgresql until (echo > /dev/tcp/zammad-postgresql/5432) &> /dev/null; do echo "zammad railsserver waiting for postgresql server to be ready..." @@ -43,5 +43,35 @@ if [ "$1" = 'zammad-railsserver' ]; then elif [ "${RAILS_SERVER}" == "unicorn" ]; then exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec unicorn -p 3000 -c config/unicorn.rb -E ${RAILS_ENV} fi - +fi + + +# zammad-scheduler +if [ "$1" = 'zammad-scheduler' ]; then + # wait for zammad process coming up + until (echo > /dev/tcp/zammad-railsserver/3000) &> /dev/null; do + echo "scheduler waiting for zammads railsserver to be ready..." + sleep 2 + done + + echo "scheduler can access raillsserver now..." + + # start scheduler + cd ${ZAMMAD_DIR} + exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec script/scheduler.rb run +fi + + +# zammad-websocket +if [ "$1" = 'zammad-websocket' ]; then + # wait for zammad process coming up + until (echo > /dev/tcp/zammad-railsserver/3000) &> /dev/null; do + echo "websocket server waiting for zammads railsserver to be ready..." + sleep 5 + done + + echo "websocket server can access raillsserver now..." + + cd ${ZAMMAD_DIR} + exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec script/websocket-server.rb -b 0.0.0.0 start fi diff --git a/docker-compose-build.yml b/docker-compose-build.yml index 3074bd4..1f0369e 100644 --- a/docker-compose-build.yml +++ b/docker-compose-build.yml @@ -2,23 +2,12 @@ version: '3.3' services: - zammad: - build: - context: . - dockerfile: containers/zammad/Dockerfile - depends_on: - - zammad-elasticsearch - - zammad-postgresql - restart: on-failure - volumes: - - data-zammad:/home/zammad - zammad-backup: build: context: . dockerfile: containers/zammad-backup/Dockerfile depends_on: - - zammad + - zammad-railsserver links: - zammad-postgresql restart: always @@ -37,7 +26,7 @@ services: context: . dockerfile: containers/zammad-nginx/Dockerfile depends_on: - - zammad + - zammad-railsserver links: - zammad-railsserver - zammad-websocket @@ -58,39 +47,42 @@ services: context: . dockerfile: containers/zammad-railsserver/Dockerfile depends_on: - - zammad + - zammad-postgresql links: - zammad-elasticsearch - zammad-postgresql restart: always volumes: - data-zammad:/home/zammad + command: ["zammad-railsserver"] zammad-scheduler: build: context: . dockerfile: containers/zammad-scheduler/Dockerfile depends_on: - - zammad + - zammad-railsserver links: - zammad-elasticsearch - zammad-postgresql restart: always volumes: - data-zammad:/home/zammad + command: ["zammad-scheduler"] zammad-websocket: build: context: . dockerfile: containers/zammad-websocket/Dockerfile depends_on: - - zammad + - zammad-railsserver links: - zammad-elasticsearch - zammad-postgresql restart: always volumes: - data-zammad:/home/zammad + command: ["zammad-websocket"] volumes: backup-zammad: diff --git a/docker-compose.yml b/docker-compose.yml index 99f8d09..d15fb41 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,21 +2,9 @@ version: '3.3' services: - zammad: - depends_on: - - zammad-elasticsearch - - zammad-postgresql - image: zammad/zammad-docker-compose:zammad - labels: - io.rancher.container.pull_image: always - io.rancher.container.start_once: 'true' - restart: on-failure - volumes: - - data-zammad:/home/zammad - zammad-backup: depends_on: - - zammad + - zammad-railsserver image: zammad/zammad-docker-compose:zammad-backup labels: io.rancher.container.pull_image: always @@ -37,7 +25,7 @@ services: zammad-nginx: depends_on: - - zammad + - zammad-railsserver image: zammad/zammad-docker-compose:zammad-nginx labels: io.rancher.container.pull_image: always @@ -58,23 +46,22 @@ services: zammad-railsserver: depends_on: - - zammad - image: zammad/zammad-docker-compose:zammad-railsserver + - zammad-postgresql + image: zammad/zammad-docker-compose:zammad labels: io.rancher.container.pull_image: always links: - zammad-elasticsearch - zammad-postgresql - depends_on: - - zammad restart: always volumes: - data-zammad:/home/zammad + command: ["zammad-railsserver"] zammad-scheduler: depends_on: - - zammad - image: zammad/zammad-docker-compose:zammad-scheduler + - zammad-railsserver + image: zammad/zammad-docker-compose:zammad labels: io.rancher.container.pull_image: always links: @@ -83,11 +70,12 @@ services: restart: always volumes: - data-zammad:/home/zammad + command: ["zammad-scheduler"] zammad-websocket: depends_on: - - zammad - image: zammad/zammad-docker-compose:zammad-websocket + - zammad-railsserver + image: zammad/zammad-docker-compose:zammad labels: io.rancher.container.pull_image: always links: @@ -96,6 +84,7 @@ services: restart: always volumes: - data-zammad:/home/zammad + command: ["zammad-websocket"] volumes: backup-zammad: diff --git a/hooks/config b/hooks/config index 1b916e1..38886e0 100644 --- a/hooks/config +++ b/hooks/config @@ -3,4 +3,4 @@ # build hooks config # -DOCKER_IMAGES="zammad zammad-backup zammad-elasticsearch zammad-nginx zammad-postgresql zammad-railsserver zammad-scheduler zammad-websocket" +DOCKER_IMAGES="zammad zammad-backup zammad-elasticsearch zammad-nginx zammad-postgresql" diff --git a/rancher-compose.yml b/rancher-compose.yml index 3c774a1..9fe5aca 100644 --- a/rancher-compose.yml +++ b/rancher-compose.yml @@ -2,10 +2,6 @@ version: '2' services: - zammad: - scale: 1 - start_on_create: true - zammad-backup: scale: 1 start_on_create: true