diff --git a/Dockerfile b/Dockerfile index 8ada015..0017339 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,4 +10,4 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \ org.label-schema.vcs-type="Git" \ org.label-schema.vendor="Zammad" \ org.label-schema.schema-version="1.0" \ - org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up --build" + org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up" diff --git a/Dockerfile.elasticsearch b/Dockerfile.elasticsearch index 360acf4..a00a4f1 100644 --- a/Dockerfile.elasticsearch +++ b/Dockerfile.elasticsearch @@ -11,6 +11,6 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \ org.label-schema.vcs-type="Git" \ org.label-schema.vendor="Zammad" \ org.label-schema.schema-version="1.0" \ - org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up --build" + org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up" RUN yes | /usr/share/elasticsearch/bin/elasticsearch-plugin install mapper-attachments diff --git a/Dockerfile.nginx b/Dockerfile.nginx index cf0b2e1..e1c927c 100644 --- a/Dockerfile.nginx +++ b/Dockerfile.nginx @@ -11,7 +11,7 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \ org.label-schema.vcs-type="Git" \ org.label-schema.vendor="Zammad" \ org.label-schema.schema-version="1.0" \ - org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up --build" + 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 diff --git a/Dockerfile.postgresql b/Dockerfile.postgresql index 02b57ae..234a50c 100644 --- a/Dockerfile.postgresql +++ b/Dockerfile.postgresql @@ -11,5 +11,5 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \ org.label-schema.vcs-type="Git" \ org.label-schema.vendor="Zammad" \ org.label-schema.schema-version="1.0" \ - org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up --build" + org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up" diff --git a/Dockerfile.zammad b/Dockerfile.zammad index f5497a7..1c1cd56 100644 --- a/Dockerfile.zammad +++ b/Dockerfile.zammad @@ -11,7 +11,7 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \ org.label-schema.vcs-type="Git" \ org.label-schema.vendor="Zammad" \ org.label-schema.schema-version="1.0" \ - org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up --build" + org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up" # Expose ports EXPOSE 3000 @@ -20,6 +20,10 @@ EXPOSE 6042 # add zammad user RUN useradd -m -d /home/zammad -s /bin/bash zammad;chown -R zammad:zammad /home/zammad +# install zammad +COPY install-zammad.sh /tmp +RUN chmod +x /tmp/install-zammad.sh;/bin/bash -l -c /tmp/install-zammad.sh + # docker init COPY docker-entrypoint.sh / RUN chown zammad:zammad /docker-entrypoint.sh;chmod +x /docker-entrypoint.sh diff --git a/README.md b/README.md index 365129f..a4e4071 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ If you like to run zammad in production you should use one of the DEB or RPM pac ### Building locally -* docker-compose -f docker-compose-build.yml up --build +* docker-compose -f docker-compose-build.yml up ## Docs diff --git a/docker-compose-build.yml b/docker-compose-build.yml index 89ccce3..677e015 100644 --- a/docker-compose-build.yml +++ b/docker-compose-build.yml @@ -4,8 +4,6 @@ services: build: context: . dockerfile: Dockerfile.elasticsearch - volumes: - - data-elasticsearch:/var/lib/elasticsearch nginx: build: context: . @@ -22,8 +20,6 @@ services: build: context: . dockerfile: Dockerfile.postgresql - volumes: - - data-postgresql:/var/lib/postgresql zammad: build: context: . @@ -38,10 +34,6 @@ services: - data-zammad:/home/zammad - data-ruby:/usr/local volumes: - data-elasticsearch: - driver: local - data-postgresql: - driver: local data-ruby: driver: local data-zammad: diff --git a/docker-compose.yml b/docker-compose.yml index b06443c..77287ca 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,8 +2,6 @@ version: '2' services: elasticsearch: image: monotek/zammad-docker-compose:elasticsearch - volumes: - - data-elasticsearch:/var/lib/elasticsearch nginx: image: monotek/zammad-docker-compose:nginx ports: @@ -16,8 +14,6 @@ services: - data-zammad:/home/zammad postgresql: image: monotek/zammad-docker-compose:postgresql - volumes: - - data-postgresql:/var/lib/postgresql zammad: image: monotek/zammad-docker-compose:zammad links: @@ -30,10 +26,6 @@ services: - data-zammad:/home/zammad - data-ruby:/usr/local volumes: - data-elasticsearch: - driver: local - data-postgresql: - driver: local data-ruby: driver: local data-zammad: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index df5c818..aef7ee7 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -7,36 +7,17 @@ GIT_BRANCH="develop" #GIT_BRANCH="unicorn" RAILS_SERVER="puma" RAILS_ENV="production" -FRESH_INSTALL="no" DEBUG="no" if [ "$1" = 'zammad' ]; then export RAILS_ENV=${RAILS_ENV} - shopt -s dotglob + cd ${ZAMMAD_DIR} + rake db:migrate &> /dev/null - if [ "${FRESH_INSTALL}" == "yes" ]; then - echo "fresh install requested. deleting everything in ${ZAMMAD_DIR}" - rm -rf ${ZAMMAD_DIR}/* - fi - - # get zammad - if [ -f ${ZAMMAD_DIR}/config/database.yml ]; then - echo "updating zammad..." - cd ${ZAMMAD_DIR} - git pull - bundle update - rake db:migrate - else - echo "installing zammad..." - cd /tmp - git clone --depth 1 -b ${GIT_BRANCH} ${GIT_URL} - mv -f /tmp/zammad/* ${ZAMMAD_DIR}/ - cd ${ZAMMAD_DIR} - bundle install --without test development - sed -e 's#.*username:.*# username: postgres#g' -e 's#.*password:.*# password: \n host: postgresql\n#g' < config/database.yml.pkgr > config/database.yml - rake db:drop + if [ $? != 0 ]; then + echo "creating db, assets, searchindex..." rake db:create rake db:migrate rake db:seed @@ -45,7 +26,7 @@ if [ "$1" = 'zammad' ]; then rake searchindex:rebuild fi - # delte logs & pids + # delete logs & pids rm ${ZAMMAD_DIR}/log/* rm ${ZAMMAD_DIR}/tmp/pids/* diff --git a/install-zammad.sh b/install-zammad.sh new file mode 100644 index 0000000..1cd28f5 --- /dev/null +++ b/install-zammad.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +ZAMMAD_DIR="/home/zammad" +GIT_URL="https://github.com/zammad/zammad.git" +GIT_BRANCH="develop" + +# install zammad +echo "installing zammad..." +cd /tmp +git clone --depth 1 -b ${GIT_BRANCH} ${GIT_URL} +cp -R /tmp/zammad/* ${ZAMMAD_DIR} +cp -R /tmp/zammad/.[!.]* ${ZAMMAD_DIR} +cd ${ZAMMAD_DIR} +rm -rf /tmp/zammad +bundle install --without test development mysql +sed -e 's#.*username:.*# username: postgres#g' -e 's#.*password:.*# password: \n host: postgresql\n#g' < config/database.yml.pkgr > config/database.yml +chown -R zammad:zammad /home/zammad/