From b419b20d3f468f9021a9ca6fa3f904f3d1997e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bauer?= Date: Wed, 8 Mar 2017 19:37:05 +0100 Subject: [PATCH] renamed containers --- .../Dockerfile | 0 containers/{nginx => zammad-nginx}/Dockerfile | 2 +- .../{nginx => zammad-nginx}/nginx-zammad.conf | 0 .../Dockerfile | 0 .../zammad-railsserver/docker-entrypoint.sh | 44 ++++++++------- .../zammad-scheduler/docker-entrypoint.sh | 12 +++-- .../zammad-websocket/docker-entrypoint.sh | 10 ++-- containers/zammad/Dockerfile | 3 +- containers/zammad/install-zammad.sh | 4 +- docker-compose-build.yml | 53 +++++++++---------- docker-compose.yml | 52 +++++++++--------- hooks/config | 2 +- rancher-compose.yml | 24 ++++----- 13 files changed, 107 insertions(+), 99 deletions(-) rename containers/{elasticsearch => zammad-elasticsearch}/Dockerfile (100%) rename containers/{nginx => zammad-nginx}/Dockerfile (89%) rename containers/{nginx => zammad-nginx}/nginx-zammad.conf (100%) rename containers/{postgresql => zammad-postgresql}/Dockerfile (100%) diff --git a/containers/elasticsearch/Dockerfile b/containers/zammad-elasticsearch/Dockerfile similarity index 100% rename from containers/elasticsearch/Dockerfile rename to containers/zammad-elasticsearch/Dockerfile diff --git a/containers/nginx/Dockerfile b/containers/zammad-nginx/Dockerfile similarity index 89% rename from containers/nginx/Dockerfile rename to containers/zammad-nginx/Dockerfile index 24388d1..b49d594 100644 --- a/containers/nginx/Dockerfile +++ b/containers/zammad-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 containers/nginx/nginx-zammad.conf /etc/nginx/conf.d/zammad.conf +ADD containers/zammad-nginx/nginx-zammad.conf /etc/nginx/conf.d/zammad.conf RUN rm /etc/nginx/conf.d/default.conf diff --git a/containers/nginx/nginx-zammad.conf b/containers/zammad-nginx/nginx-zammad.conf similarity index 100% rename from containers/nginx/nginx-zammad.conf rename to containers/zammad-nginx/nginx-zammad.conf diff --git a/containers/postgresql/Dockerfile b/containers/zammad-postgresql/Dockerfile similarity index 100% rename from containers/postgresql/Dockerfile rename to containers/zammad-postgresql/Dockerfile diff --git a/containers/zammad-railsserver/docker-entrypoint.sh b/containers/zammad-railsserver/docker-entrypoint.sh index 83b72ea..c475632 100644 --- a/containers/zammad-railsserver/docker-entrypoint.sh +++ b/containers/zammad-railsserver/docker-entrypoint.sh @@ -2,29 +2,35 @@ if [ "$1" = 'zammad-railsserver' ]; then - cd ${ZAMMAD_DIR} - bundle exec rake db:migrate &> /dev/null + # wait for postgres process coming up on zammad-postgresql + until echo > /dev/tcp/zammad-postgresql/5432; do + echo "waiting for postgres to be ready..." + sleep 5 + done - if [ $? != 0 ]; then - echo "creating db & searchindex..." - bundle exec rake db:create - bundle exec rake db:migrate - bundle exec rake db:seed - bundle exec rails r "Setting.set('es_url', 'http://elasticsearch:9200')" - bundle exec rake searchindex:rebuild - fi + cd ${ZAMMAD_DIR} + bundle exec rake db:migrate &> /dev/null - # delete logs - find ${ZAMMAD_DIR}/log -iname *.log -exec rm {} \; + if [ $? != 0 ]; then + echo "creating db & searchindex..." + bundle exec rake db:create + bundle exec rake db:migrate + bundle exec rake db:seed + bundle exec rails r "Setting.set('es_url', 'http://elasticsearch:9200')" + bundle exec rake searchindex:rebuild + fi - # run zammad - echo "starting zammad..." - echo "zammad will be accessable on http://localhost in some seconds" + # delete logs + find ${ZAMMAD_DIR}/log -iname *.log -exec rm {} \; - if [ "${RAILS_SERVER}" == "puma" ]; then - bundle exec puma -b tcp://0.0.0.0:3000 -e ${RAILS_ENV} + # run zammad + echo "starting zammad..." + echo "zammad will be accessable on http://localhost in some seconds" + + if [ "${RAILS_SERVER}" == "puma" ]; then + bundle exec puma -b tcp://0.0.0.0:3000 -e ${RAILS_ENV} elif [ "${RAILS_SERVER}" == "unicorn" ]; then - bundle exec unicorn -p 3000 -c config/unicorn.rb -E ${RAILS_ENV} - fi + bundle exec unicorn -p 3000 -c config/unicorn.rb -E ${RAILS_ENV} + fi fi diff --git a/containers/zammad-scheduler/docker-entrypoint.sh b/containers/zammad-scheduler/docker-entrypoint.sh index 7dd2ce3..79a4ddb 100644 --- a/containers/zammad-scheduler/docker-entrypoint.sh +++ b/containers/zammad-scheduler/docker-entrypoint.sh @@ -1,9 +1,13 @@ #!/bin/bash if [ "$1" = 'zammad-scheduler' ]; then + # wait for zammad process coming up + until echo > /dev/tcp/zammad-railsserver/3000; do + echo "waiting for zammad to be ready..." + sleep 2 + done - # start scheduler - cd ${ZAMMAD_DIR} - bundle exec script/scheduler.rb run - + # start scheduler + cd ${ZAMMAD_DIR} + bundle exec script/scheduler.rb run fi diff --git a/containers/zammad-websocket/docker-entrypoint.sh b/containers/zammad-websocket/docker-entrypoint.sh index a624f29..713b010 100644 --- a/containers/zammad-websocket/docker-entrypoint.sh +++ b/containers/zammad-websocket/docker-entrypoint.sh @@ -1,8 +1,12 @@ #!/bin/bash if [ "$1" = 'zammad-websocket' ]; then + # wait for zammad process coming up + until echo > /dev/tcp/zammad-railsserver/3000; do + echo "waiting for zammad to be ready..." + sleep 5 + done - cd ${ZAMMAD_DIR} - bundle exec script/websocket-server.rb -b 0.0.0.0 start - + cd ${ZAMMAD_DIR} + bundle exec script/websocket-server.rb -b 0.0.0.0 start fi diff --git a/containers/zammad/Dockerfile b/containers/zammad/Dockerfile index d007adf..4301321 100644 --- a/containers/zammad/Dockerfile +++ b/containers/zammad/Dockerfile @@ -27,7 +27,6 @@ COPY containers/zammad/install-zammad.sh /tmp RUN chmod +x /tmp/install-zammad.sh;/bin/bash -l -c /tmp/install-zammad.sh # cleanup -RUN apt-get remove --purge -y git-core build-essential bzip2 libffi-dev libgdbm3 libssl-dev procps zlib1g-dev && \ +RUN apt-get remove --purge -y build-essential bzip2 git-core libffi-dev libgdbm3 libssl-dev procps zlib1g-dev && \ apt-get autoremove -y && \ rm -rf /var/lib/apt/lists/* - diff --git a/containers/zammad/install-zammad.sh b/containers/zammad/install-zammad.sh index 727291c..ba98868 100644 --- a/containers/zammad/install-zammad.sh +++ b/containers/zammad/install-zammad.sh @@ -17,13 +17,13 @@ bundle install --without test development mysql contrib/packager.io/fetch_locales.rb # set nulldb database adapter for assets precompile -sed -e 's#.*adapter: postgresql# adapter: nulldb#g' -e 's#.*username:.*# username: postgres#g' -e 's#.*password:.*# password: \n host: postgresql\n#g' < config/database.yml.pkgr > config/database.yml +sed -e 's#.*adapter: postgresql# adapter: nulldb#g' -e 's#.*username:.*# username: postgres#g' -e 's#.*password:.*# password: \n host: zammad-postgresql\n#g' < config/database.yml.pkgr > config/database.yml # assets precompile bundle exec rake assets:precompile # set postgresql database adapter -sed -e 's#.*adapter: postgresql# adapter: postgresql#g' -e 's#.*username:.*# username: postgres#g' -e 's#.*password:.*# password: \n host: postgresql\n#g' < config/database.yml.pkgr > config/database.yml +sed -e 's#.*adapter: postgresql# adapter: postgresql#g' -e 's#.*username:.*# username: postgres#g' -e 's#.*password:.*# password: \n host: zammad-postgresql\n#g' < config/database.yml.pkgr > config/database.yml # delete assets precompile cache rm -r tmp/cache diff --git a/docker-compose-build.yml b/docker-compose-build.yml index 3e3d83a..50cecfc 100644 --- a/docker-compose-build.yml +++ b/docker-compose-build.yml @@ -2,16 +2,27 @@ version: '2' services: - elasticsearch: + zammad: build: context: . - dockerfile: containers/elasticsearch/Dockerfile + dockerfile: containers/zammad/Dockerfile + depends_on: + - zammad-elasticsearch + - zammad-postgresql + restart: on-failure + volumes: + - data-zammad:/home/zammad + + zammad-elasticsearch: + build: + context: . + dockerfile: containers/zammad-elasticsearch/Dockerfile restart: always - nginx: + zammad-nginx: build: context: . - dockerfile: containers/nginx/Dockerfile + dockerfile: containers/zammad-nginx/Dockerfile depends_on: - zammad links: @@ -23,31 +34,21 @@ services: volumes: - data-zammad:/home/zammad - postgresql: + zammad-postgresql: build: context: . - dockerfile: containers/postgresql/Dockerfile + dockerfile: containers/zammad-postgresql/Dockerfile restart: always - zammad: - build: - context: . - 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 + - zammad-elasticsearch + - zammad-postgresql restart: always zammad-scheduler: @@ -55,12 +56,10 @@ services: context: . dockerfile: containers/zammad-scheduler/Dockerfile depends_on: - - elasticsearch - - postgresql - - zammad + - zammad-railsserver links: - - elasticsearch - - postgresql + - zammad-elasticsearch + - zammad-postgresql restart: always zammad-websocket: @@ -68,12 +67,10 @@ services: context: . dockerfile: containers/zammad-websocket/Dockerfile depends_on: - - elasticsearch - - postgresql - - zammad + - zammad-railsserver links: - - elasticsearch - - postgresql + - zammad-elasticsearch + - zammad-postgresql restart: always volumes: diff --git a/docker-compose.yml b/docker-compose.yml index 4e03fd9..6114f2d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,16 +2,28 @@ version: '2' services: - elasticsearch: - image: zammad/zammad-docker-compose:elasticsearch + 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-elasticsearch: + image: zammad/zammad-docker-compose:zammad-elasticsearch labels: io.rancher.container.pull_image: always restart: always - nginx: + zammad-nginx: depends_on: - zammad - image: zammad/zammad-docker-compose:nginx + image: zammad/zammad-docker-compose:zammad-nginx labels: io.rancher.container.pull_image: always links: @@ -23,32 +35,21 @@ services: volumes: - data-zammad:/home/zammad - postgresql: - image: zammad/zammad-docker-compose:postgresql + zammad-postgresql: + image: zammad/zammad-docker-compose:zammad-postgresql labels: io.rancher.container.pull_image: always restart: always - zammad: - 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-railsserver: image: zammad/zammad-docker-compose:zammad-railsserver labels: io.rancher.container.pull_image: always links: - - elasticsearch - - postgresql + - zammad-elasticsearch + - zammad-postgresql - zammad depends_on: - - elasticsearch - - postgresql - zammad restart: always @@ -57,13 +58,11 @@ services: labels: io.rancher.container.pull_image: always links: - - elasticsearch - - postgresql + - zammad-elasticsearch + - zammad-postgresql - zammad depends_on: - - elasticsearch - - postgresql - - zammad + - zammad-railsserver restart: always zammad-websocket: @@ -71,11 +70,10 @@ services: labels: io.rancher.container.pull_image: always links: - - postgresql + - zammad-postgresql - zammad depends_on: - - postgresql - - zammad + - zammad-railsserver restart: always volumes: diff --git a/hooks/config b/hooks/config index c9dde9f..c872bc2 100644 --- a/hooks/config +++ b/hooks/config @@ -3,4 +3,4 @@ # build hooks config # -DOCKER_IMAGES="elasticsearch nginx postgresql zammad zammad-railsserver zammad-scheduler zammad-websocket" +DOCKER_IMAGES="zammad zammad-elasticsearch zammad-nginx zammad-postgresql zammad-railsserver zammad-scheduler zammad-websocket" diff --git a/rancher-compose.yml b/rancher-compose.yml index c603be7..0b905c4 100644 --- a/rancher-compose.yml +++ b/rancher-compose.yml @@ -2,22 +2,22 @@ version: '2' services: - elasticsearch: - scale: 1 - start_on_create: true - - nginx: - scale: 1 - start_on_create: true - - postgresql: - scale: 1 - start_on_create: true - zammad: scale: 1 start_on_create: true + zammad-elasticsearch: + scale: 1 + start_on_create: true + + zammad-nginx: + scale: 1 + start_on_create: true + + zammad-postgresql: + scale: 1 + start_on_create: true + zammad-scheduler: scale: 1 start_on_create: true