diff --git a/.env b/.env index 5d7c3f1..56f17e2 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ # don't forget to add the minus before the version -# example: VERSION=-2.1.0-13 +# example: VERSION=-2.9.0-1 IMAGE_REPO=zammad/zammad-docker-compose VERSION= -RESTART=always \ No newline at end of file +RESTART=always diff --git a/Dockerfile b/Dockerfile index d17aad0..822e3e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,5 +9,5 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \ 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.schema-version="2.9.0" \ org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up" diff --git a/containers/zammad-elasticsearch/Dockerfile b/containers/zammad-elasticsearch/Dockerfile index 40f442f..cc89306 100644 --- a/containers/zammad-elasticsearch/Dockerfile +++ b/containers/zammad-elasticsearch/Dockerfile @@ -10,7 +10,7 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \ 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.schema-version="2.9.0" \ org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up" RUN /usr/share/elasticsearch/bin/elasticsearch-plugin remove x-pack --purge && \ diff --git a/containers/zammad-memcached/Dockerfile b/containers/zammad-memcached/Dockerfile index bc1ecd4..82bb04b 100644 --- a/containers/zammad-memcached/Dockerfile +++ b/containers/zammad-memcached/Dockerfile @@ -11,7 +11,7 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \ 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.schema-version="2.9.0" \ org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up" # docker init diff --git a/containers/zammad-postgresql/Dockerfile b/containers/zammad-postgresql/Dockerfile index 6a364c0..aa47db6 100644 --- a/containers/zammad-postgresql/Dockerfile +++ b/containers/zammad-postgresql/Dockerfile @@ -15,7 +15,7 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \ 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.schema-version="2.9.0" \ org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up" # copy backup script diff --git a/containers/zammad/Dockerfile b/containers/zammad/Dockerfile index ffb05f1..a123e03 100644 --- a/containers/zammad/Dockerfile +++ b/containers/zammad/Dockerfile @@ -1,18 +1,33 @@ -FROM ruby:2.4.4-slim +FROM ruby:2.4.4-slim AS builder +# note: zammad is currently incompatible to alpine because of: +# https://github.com/docker-library/ruby/issues/113 + MAINTAINER Zammad ARG BUILD_DATE +ARG DEBIAN_FRONTEND=noninteractive -ENV ZAMMAD_DIR /opt/zammad -ENV ZAMMAD_USER zammad -ENV RAILS_ENV production -ENV RAILS_SERVER puma -ENV PROJECT_URL https://github.com/zammad/zammad -ENV GIT_URL ${PROJECT_URL}.git ENV GIT_BRANCH stable -ENV ZAMMAD_TMP_DIR /tmp/zammad-${GIT_BRANCH} -ENV TAR_GZ_URL ${PROJECT_URL}/archive/${GIT_BRANCH}.tar.gz +ENV GIT_URL ${PROJECT_URL}.git ENV GOSU_VERSION 1.11 +ENV PROJECT_URL https://github.com/zammad/zammad +ENV RAILS_ENV production +ENV TAR_GZ_URL ${PROJECT_URL}/archive/${GIT_BRANCH}.tar.gz +ENV ZAMMAD_DIR /opt/zammad ENV ZAMMAD_READY_FILE ${ZAMMAD_DIR}/tmp/zammad.ready +ENV ZAMMAD_TMP_DIR /tmp/zammad-${GIT_BRANCH} +ENV ZAMMAD_USER zammad + +# install zammad +COPY containers/zammad/setup.sh /tmp +RUN chmod +x /tmp/setup.sh; \ + /tmp/setup.sh install + + +FROM ruby:2.4.4-slim + +MAINTAINER Zammad +ARG BUILD_DATE +ARG DEBIAN_FRONTEND=noninteractive LABEL org.label-schema.build-date="$BUILD_DATE" \ org.label-schema.name="Zammad" \ @@ -22,33 +37,23 @@ LABEL org.label-schema.build-date="$BUILD_DATE" \ 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.schema-version="2.9.0" \ org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up" -# install dependencies & gosu -RUN BUILD_DEPENDENCIES="build-essential ca-certificates curl dirmngr git gnupg2 libffi-dev libpq5 libpq-dev nginx rsync" && \ - set -ex && \ - apt-get update && apt-get install -y --no-install-recommends ${BUILD_DEPENDENCIES} && rm -rf /var/lib/apt/lists/* && \ - curl -s -J -L -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" && \ - chmod +x /usr/local/bin/gosu && \ - gosu nobody true +ENV GIT_BRANCH stable +ENV RAILS_ENV production +ENV ZAMMAD_DIR /opt/zammad +ENV ZAMMAD_READY_FILE ${ZAMMAD_DIR}/tmp/zammad.ready +ENV ZAMMAD_TMP_DIR /tmp/zammad-${GIT_BRANCH} +ENV ZAMMAD_USER zammad -# install zammad -RUN groupadd -g 1000 ${ZAMMAD_USER} && \ - useradd -M -d ${ZAMMAD_DIR} -s /bin/bash -u 1000 -g 1000 ${ZAMMAD_USER} && \ - cd $(dirname ${ZAMMAD_TMP_DIR}) && \ - curl -s -J -L -O "${TAR_GZ_URL}" && \ - tar -xzf zammad-${GIT_BRANCH}.tar.gz && \ - rm zammad-${GIT_BRANCH}.tar.gz && \ - cd ${ZAMMAD_TMP_DIR} && \ - bundle install --without test development mysql && \ - contrib/packager.io/fetch_locales.rb && \ - sed -e 's#.*adapter: postgresql# adapter: nulldb#g' -e 's#.*username:.*# username: postgres#g' -e 's#.*password:.*# password: \n host: zammad-postgresql\n#g' < contrib/packager.io/database.yml.pkgr > config/database.yml && \ - sed -i '/# Use a different logger for distributed setups./a \ \ config.logger = Logger.new(STDOUT)' config/environments/production.rb && \ - sed -i 's/.*scheduler_\(err\|out\).log.*//g' script/scheduler.rb && \ - bundle exec rake assets:precompile && \ - rm -r tmp/cache && \ - chown -R ${ZAMMAD_USER}:${ZAMMAD_USER} ${ZAMMAD_TMP_DIR} +COPY containers/zammad/setup.sh /tmp +RUN chmod +x /tmp/setup.sh; \ + /tmp/setup.sh run + +COPY --from=builder ${ZAMMAD_TMP_DIR} ${ZAMMAD_TMP_DIR} +COPY --from=builder /usr/local/bin/gosu /usr/local/bin/gosu +COPY --from=builder /usr/local/bundle /usr/local/bundle # docker init COPY containers/zammad/docker-entrypoint.sh / diff --git a/containers/zammad/docker-entrypoint.sh b/containers/zammad/docker-entrypoint.sh old mode 100644 new mode 100755 index 63802ce..3d66b13 --- a/containers/zammad/docker-entrypoint.sh +++ b/containers/zammad/docker-entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e @@ -129,10 +129,12 @@ if [ "$1" = 'zammad-railsserver' ]; then echo "starting railsserver..." + #shellcheck disable=SC2101 exec gosu "${ZAMMAD_USER}":"${ZAMMAD_USER}" bundle exec rails server puma -b [::] -p "${ZAMMAD_RAILSSERVER_PORT}" -e "${RAILS_ENV}" fi + # zammad-scheduler if [ "$1" = 'zammad-scheduler' ]; then check_zammad_ready diff --git a/containers/zammad/setup.sh b/containers/zammad/setup.sh new file mode 100644 index 0000000..cb94feb --- /dev/null +++ b/containers/zammad/setup.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env sh +set -e + +# install dependencies +if [ "$1" = 'install' ]; then + PACKAGES="build-essential curl git libimlib2-dev libpq-dev" +elif [ "$1" = 'run' ]; then + PACKAGES="curl libimlib2 libimlib2-dev libpq5 nginx rsync" +fi + +apt-get update +apt-get upgrade -y +apt-get install -y --no-install-recommends ${PACKAGES} +rm -rf /var/lib/apt/lists/* + +# install gosu +if [ "$1" = 'install' ]; then + curl -s -J -L -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" + chmod +x /usr/local/bin/gosu + gosu nobody true +fi + +# install zammad +groupadd -g 1000 "${ZAMMAD_USER}" +useradd -M -d "${ZAMMAD_DIR}" -s /bin/bash -u 1000 -g 1000 "${ZAMMAD_USER}" + +if [ "$1" = 'install' ]; then + cd "$(dirname "${ZAMMAD_TMP_DIR}")" + curl -s -J -L -O "${TAR_GZ_URL}" + tar -xzf zammad-"${GIT_BRANCH}".tar.gz + rm zammad-"${GIT_BRANCH}".tar.gz + cd "${ZAMMAD_TMP_DIR}" + bundle install --without test development mysql + contrib/packager.io/fetch_locales.rb + sed -e 's#.*adapter: postgresql# adapter: nulldb#g' -e 's#.*username:.*# username: postgres#g' -e 's#.*password:.*# password: \n host: zammad-postgresql\n#g' < contrib/packager.io/database.yml.pkgr > config/database.yml + sed -i '/# Use a different logger for distributed setups./a \ \ config.logger = Logger.new(STDOUT)' config/environments/production.rb + sed -i 's/.*scheduler_\(err\|out\).log.*//g' script/scheduler.rb + bundle exec rake assets:precompile + rm -r tmp/cache + chown -R "${ZAMMAD_USER}":"${ZAMMAD_USER}" "${ZAMMAD_TMP_DIR}" +fi