diff --git a/Dockerfile.elasticsearch b/containers/elasticsearch/Dockerfile similarity index 100% rename from Dockerfile.elasticsearch rename to containers/elasticsearch/Dockerfile diff --git a/Dockerfile.nginx b/containers/nginx/Dockerfile similarity index 90% rename from Dockerfile.nginx rename to containers/nginx/Dockerfile index 8d1a8da..24388d1 100644 --- a/Dockerfile.nginx +++ b/containers/nginx/Dockerfile @@ -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 diff --git a/nginx-zammad.conf b/containers/nginx/nginx-zammad.conf similarity index 89% rename from nginx-zammad.conf rename to containers/nginx/nginx-zammad.conf index 30fa510..32954ab 100644 --- a/nginx-zammad.conf +++ b/containers/nginx/nginx-zammad.conf @@ -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; diff --git a/Dockerfile.postgresql b/containers/postgresql/Dockerfile similarity index 100% rename from Dockerfile.postgresql rename to containers/postgresql/Dockerfile diff --git a/containers/zammad-railsserver/Dockerfile b/containers/zammad-railsserver/Dockerfile new file mode 100644 index 0000000..cac48eb --- /dev/null +++ b/containers/zammad-railsserver/Dockerfile @@ -0,0 +1,31 @@ +FROM zammad/zammad-docker-compose:zammad +MAINTAINER Zammad +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"] diff --git a/docker-entrypoint.sh b/containers/zammad-railsserver/docker-entrypoint.sh similarity index 77% rename from docker-entrypoint.sh rename to containers/zammad-railsserver/docker-entrypoint.sh index f3d7195..83b72ea 100644 --- a/docker-entrypoint.sh +++ b/containers/zammad-railsserver/docker-entrypoint.sh @@ -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} diff --git a/containers/zammad-scheduler/Dockerfile b/containers/zammad-scheduler/Dockerfile new file mode 100644 index 0000000..2858ab5 --- /dev/null +++ b/containers/zammad-scheduler/Dockerfile @@ -0,0 +1,28 @@ +FROM zammad/zammad-docker-compose:zammad +MAINTAINER Zammad +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"] diff --git a/containers/zammad-scheduler/docker-entrypoint.sh b/containers/zammad-scheduler/docker-entrypoint.sh new file mode 100644 index 0000000..7dd2ce3 --- /dev/null +++ b/containers/zammad-scheduler/docker-entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +if [ "$1" = 'zammad-scheduler' ]; then + + # start scheduler + cd ${ZAMMAD_DIR} + bundle exec script/scheduler.rb run + +fi diff --git a/containers/zammad-websocket/Dockerfile b/containers/zammad-websocket/Dockerfile new file mode 100644 index 0000000..3f40d41 --- /dev/null +++ b/containers/zammad-websocket/Dockerfile @@ -0,0 +1,31 @@ +FROM zammad/zammad-docker-compose:zammad +MAINTAINER Zammad +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"] diff --git a/containers/zammad-websocket/docker-entrypoint.sh b/containers/zammad-websocket/docker-entrypoint.sh new file mode 100644 index 0000000..a624f29 --- /dev/null +++ b/containers/zammad-websocket/docker-entrypoint.sh @@ -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 diff --git a/Dockerfile.zammad b/containers/zammad/Dockerfile similarity index 77% rename from Dockerfile.zammad rename to containers/zammad/Dockerfile index fa5931a..ca1d567 100644 --- a/Dockerfile.zammad +++ b/containers/zammad/Dockerfile @@ -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"] diff --git a/install-zammad.sh b/containers/zammad/install-zammad.sh similarity index 96% rename from install-zammad.sh rename to containers/zammad/install-zammad.sh index a55d972..727291c 100644 --- a/install-zammad.sh +++ b/containers/zammad/install-zammad.sh @@ -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 diff --git a/docker-compose-build.yml b/docker-compose-build.yml index 795d0c4..3e3d83a 100644 --- a/docker-compose-build.yml +++ b/docker-compose-build.yml @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 7324732..9dc593d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/hooks/build b/hooks/build index 5e9d7ad..49b2204 100755 --- a/hooks/build +++ b/hooks/build @@ -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 diff --git a/hooks/config b/hooks/config index 4337c80..c9dde9f 100644 --- a/hooks/config +++ b/hooks/config @@ -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" diff --git a/hooks/push b/hooks/push deleted file mode 100755 index d992657..0000000 --- a/hooks/push +++ /dev/null @@ -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 -