use multistage docker image
This commit is contained in:
parent
151371c39a
commit
5aa5151c88
4
.env
4
.env
@ -1,5 +1,5 @@
|
|||||||
# don't forget to add the minus before the version
|
# 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
|
IMAGE_REPO=zammad/zammad-docker-compose
|
||||||
VERSION=
|
VERSION=
|
||||||
RESTART=always
|
RESTART=always
|
||||||
|
@ -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-url="https://github.com/zammad/zammad" \
|
||||||
org.label-schema.vcs-type="Git" \
|
org.label-schema.vcs-type="Git" \
|
||||||
org.label-schema.vendor="Zammad" \
|
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"
|
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
|
||||||
|
@ -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-url="https://github.com/zammad/zammad" \
|
||||||
org.label-schema.vcs-type="Git" \
|
org.label-schema.vcs-type="Git" \
|
||||||
org.label-schema.vendor="Zammad" \
|
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"
|
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 && \
|
RUN /usr/share/elasticsearch/bin/elasticsearch-plugin remove x-pack --purge && \
|
||||||
|
@ -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-url="https://github.com/zammad/zammad" \
|
||||||
org.label-schema.vcs-type="Git" \
|
org.label-schema.vcs-type="Git" \
|
||||||
org.label-schema.vendor="Zammad" \
|
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"
|
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
|
||||||
|
|
||||||
# docker init
|
# docker init
|
||||||
|
@ -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-url="https://github.com/zammad/zammad" \
|
||||||
org.label-schema.vcs-type="Git" \
|
org.label-schema.vcs-type="Git" \
|
||||||
org.label-schema.vendor="Zammad" \
|
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"
|
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
|
||||||
|
|
||||||
# copy backup script
|
# copy backup script
|
||||||
|
@ -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 <info@zammad.org>
|
MAINTAINER Zammad <info@zammad.org>
|
||||||
ARG BUILD_DATE
|
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 GIT_BRANCH stable
|
||||||
ENV ZAMMAD_TMP_DIR /tmp/zammad-${GIT_BRANCH}
|
ENV GIT_URL ${PROJECT_URL}.git
|
||||||
ENV TAR_GZ_URL ${PROJECT_URL}/archive/${GIT_BRANCH}.tar.gz
|
|
||||||
ENV GOSU_VERSION 1.11
|
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_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 <info@zammad.org>
|
||||||
|
ARG BUILD_DATE
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
LABEL org.label-schema.build-date="$BUILD_DATE" \
|
LABEL org.label-schema.build-date="$BUILD_DATE" \
|
||||||
org.label-schema.name="Zammad" \
|
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-url="https://github.com/zammad/zammad" \
|
||||||
org.label-schema.vcs-type="Git" \
|
org.label-schema.vcs-type="Git" \
|
||||||
org.label-schema.vendor="Zammad" \
|
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"
|
org.label-schema.docker.cmd="sysctl -w vm.max_map_count=262144;docker-compose up"
|
||||||
|
|
||||||
# install dependencies & gosu
|
ENV GIT_BRANCH stable
|
||||||
RUN BUILD_DEPENDENCIES="build-essential ca-certificates curl dirmngr git gnupg2 libffi-dev libpq5 libpq-dev nginx rsync" && \
|
ENV RAILS_ENV production
|
||||||
set -ex && \
|
ENV ZAMMAD_DIR /opt/zammad
|
||||||
apt-get update && apt-get install -y --no-install-recommends ${BUILD_DEPENDENCIES} && rm -rf /var/lib/apt/lists/* && \
|
ENV ZAMMAD_READY_FILE ${ZAMMAD_DIR}/tmp/zammad.ready
|
||||||
curl -s -J -L -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$(dpkg --print-architecture)" && \
|
ENV ZAMMAD_TMP_DIR /tmp/zammad-${GIT_BRANCH}
|
||||||
chmod +x /usr/local/bin/gosu && \
|
ENV ZAMMAD_USER zammad
|
||||||
gosu nobody true
|
|
||||||
|
|
||||||
# install zammad
|
COPY containers/zammad/setup.sh /tmp
|
||||||
RUN groupadd -g 1000 ${ZAMMAD_USER} && \
|
RUN chmod +x /tmp/setup.sh; \
|
||||||
useradd -M -d ${ZAMMAD_DIR} -s /bin/bash -u 1000 -g 1000 ${ZAMMAD_USER} && \
|
/tmp/setup.sh run
|
||||||
cd $(dirname ${ZAMMAD_TMP_DIR}) && \
|
|
||||||
curl -s -J -L -O "${TAR_GZ_URL}" && \
|
COPY --from=builder ${ZAMMAD_TMP_DIR} ${ZAMMAD_TMP_DIR}
|
||||||
tar -xzf zammad-${GIT_BRANCH}.tar.gz && \
|
COPY --from=builder /usr/local/bin/gosu /usr/local/bin/gosu
|
||||||
rm zammad-${GIT_BRANCH}.tar.gz && \
|
COPY --from=builder /usr/local/bundle /usr/local/bundle
|
||||||
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}
|
|
||||||
|
|
||||||
# docker init
|
# docker init
|
||||||
COPY containers/zammad/docker-entrypoint.sh /
|
COPY containers/zammad/docker-entrypoint.sh /
|
||||||
|
4
containers/zammad/docker-entrypoint.sh
Normal file → Executable file
4
containers/zammad/docker-entrypoint.sh
Normal file → Executable file
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@ -129,10 +129,12 @@ if [ "$1" = 'zammad-railsserver' ]; then
|
|||||||
|
|
||||||
echo "starting railsserver..."
|
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}"
|
exec gosu "${ZAMMAD_USER}":"${ZAMMAD_USER}" bundle exec rails server puma -b [::] -p "${ZAMMAD_RAILSSERVER_PORT}" -e "${RAILS_ENV}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# zammad-scheduler
|
# zammad-scheduler
|
||||||
if [ "$1" = 'zammad-scheduler' ]; then
|
if [ "$1" = 'zammad-scheduler' ]; then
|
||||||
check_zammad_ready
|
check_zammad_ready
|
||||||
|
41
containers/zammad/setup.sh
Normal file
41
containers/zammad/setup.sh
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user