added image build to ci & change db checks / migration (#142)
* updated image to 3.3.0-11 Signed-off-by: André Bauer <monotek23@gmail.com> * add image build to ci / changed db cehcks Signed-off-by: André Bauer <monotek23@gmail.com> * added repo user var Signed-off-by: André Bauer <monotek23@gmail.com> * added needs Signed-off-by: André Bauer <monotek23@gmail.com> * added executable bit Signed-off-by: André Bauer <monotek23@gmail.com> * test Signed-off-by: André Bauer <monotek23@gmail.com> * test Signed-off-by: André Bauer <monotek23@gmail.com> * test Signed-off-by: André Bauer <monotek23@gmail.com>
This commit is contained in:
parent
de6941235d
commit
f93db7f2e8
22
.github/docker-image-build.sh
vendored
Executable file
22
.github/docker-image-build.sh
vendored
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# build zammads docker & docker-compose images
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
DOCKER_IMAGES="zammad zammad-elasticsearch zammad-postgresql"
|
||||||
|
DOCKER_IMAGE_TAG="ci-snapshot"
|
||||||
|
DOCKER_REGISTRY="index.docker.io"
|
||||||
|
DOCKER_REPOSITORY="zammad-docker-compose"
|
||||||
|
|
||||||
|
# dockerhub auth
|
||||||
|
echo "${DOCKER_PASSWORD}" | docker login --username="${DOCKER_USERNAME}" --password-stdin
|
||||||
|
|
||||||
|
# shellcheck disable=SC2153
|
||||||
|
for DOCKER_IMAGE in ${DOCKER_IMAGES}; do
|
||||||
|
echo "Build Zammad Docker image ${DOCKER_IMAGE} with version ${DOCKER_IMAGE_TAG} for DockerHubs ${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY} repo"
|
||||||
|
|
||||||
|
docker build --pull --no-cache --build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" -t "${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}-${DOCKER_IMAGE_TAG}" -f "containers/${DOCKER_IMAGE}/Dockerfile" .
|
||||||
|
docker push "${DOCKER_REGISTRY}/${REPO_USER}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}-${DOCKER_IMAGE_TAG}"
|
||||||
|
done
|
18
.github/workflows/ci.yaml
vendored
18
.github/workflows/ci.yaml
vendored
@ -32,12 +32,30 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
dockerfile: containers/zammad-postgresql/Dockerfile
|
dockerfile: containers/zammad-postgresql/Dockerfile
|
||||||
|
|
||||||
|
build-containers:
|
||||||
|
needs:
|
||||||
|
- lint-bash-scripts
|
||||||
|
- lint-docker-files
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
REPO_USER: ${{ secrets.REPO_USER }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
- name: build docker containers
|
||||||
|
run: .github/docker-image-build.sh
|
||||||
|
|
||||||
test-docker-compose:
|
test-docker-compose:
|
||||||
|
needs: build-containers
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v1
|
||||||
|
- name: use images build by ci
|
||||||
|
run: sed -i -e 's#VERSION=.*#VERSION=-ci-snapshot#g' < .env
|
||||||
- name: pull container images
|
- name: pull container images
|
||||||
run: docker-compose pull
|
run: docker-compose pull
|
||||||
- name: run docker-compose up
|
- name: run docker-compose up
|
||||||
|
@ -49,34 +49,21 @@ if [ "$1" = 'zammad-init' ]; then
|
|||||||
# configure memcache
|
# configure memcache
|
||||||
sed -i -e "s/.*config.cache_store.*file_store.*cache_file_store.*/ config.cache_store = :dalli_store, '${MEMCACHED_HOST}:${MEMCACHED_PORT}'\\n config.session_store = :dalli_store, '${MEMCACHED_HOST}:${MEMCACHED_PORT}'/" config/application.rb
|
sed -i -e "s/.*config.cache_store.*file_store.*cache_file_store.*/ config.cache_store = :dalli_store, '${MEMCACHED_HOST}:${MEMCACHED_PORT}'\\n config.session_store = :dalli_store, '${MEMCACHED_HOST}:${MEMCACHED_PORT}'/" config/application.rb
|
||||||
|
|
||||||
echo "initialising / updating database..."
|
|
||||||
|
|
||||||
# check if database exists / update to new version
|
# check if database exists / update to new version
|
||||||
set +e
|
echo "initialising / updating database..."
|
||||||
bundle exec rake db:migrate &> /dev/null
|
if ! (bundle exec rails r 'puts User.any?' 2> /dev/null | grep -q true); then
|
||||||
DB_MIGRATE="$?"
|
if [ "${POSTGRESQL_DB_CREATE}" == "true" ]; then
|
||||||
|
|
||||||
# check if database is populated
|
|
||||||
if [ "${DB_MIGRATE}" == "0" ]; then
|
|
||||||
bundle exec rails r "Setting.set('es_url', '${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}')" &> /dev/null
|
|
||||||
DB_SETTINGS="$?"
|
|
||||||
fi
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# create database if not exists
|
|
||||||
if [ "${DB_MIGRATE}" != "0" ] && [ "${POSTGRESQL_DB_CREATE}" == "true" ]; then
|
|
||||||
echo "creating database..."
|
|
||||||
bundle exec rake db:create
|
bundle exec rake db:create
|
||||||
fi
|
fi
|
||||||
|
bundle exec rake db:migrate
|
||||||
# populate database and create autowizard.json on first install
|
|
||||||
if [ "${DB_SETTINGS}" != "0" ]; then
|
|
||||||
echo "seeding database..."
|
|
||||||
bundle exec rake db:seed
|
bundle exec rake db:seed
|
||||||
|
|
||||||
|
# create autowizard.json on first install
|
||||||
if [ -n "${AUTOWIZARD_JSON}" ]; then
|
if [ -n "${AUTOWIZARD_JSON}" ]; then
|
||||||
echo "${AUTOWIZARD_JSON}" | base64 -d > auto_wizard.json
|
echo "${AUTOWIZARD_JSON}" | base64 -d > auto_wizard.json
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
bundle exec rake db:migrate
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# es config
|
# es config
|
||||||
@ -116,11 +103,6 @@ fi
|
|||||||
if [ "$1" = 'zammad-nginx' ]; then
|
if [ "$1" = 'zammad-nginx' ]; then
|
||||||
check_zammad_ready
|
check_zammad_ready
|
||||||
|
|
||||||
# configure nginx
|
|
||||||
if ! env | grep -q KUBERNETES; then
|
|
||||||
sed -e "s#server .*:3000#server ${ZAMMAD_RAILSSERVER_HOST}:${ZAMMAD_RAILSSERVER_PORT}#g" -e "s#server .*:6042#server ${ZAMMAD_WEBSOCKET_HOST}:${ZAMMAD_WEBSOCKET_PORT}#g" -e "s#server_name .*#server_name ${NGINX_SERVER_NAME};#g" -e 's#/var/log/nginx/zammad.\(access\|error\).log#/dev/stdout#g' < contrib/nginx/zammad.conf > /etc/nginx/sites-enabled/default
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "starting nginx..."
|
echo "starting nginx..."
|
||||||
|
|
||||||
exec /usr/sbin/nginx -g 'daemon off;'
|
exec /usr/sbin/nginx -g 'daemon off;'
|
||||||
|
Loading…
Reference in New Issue
Block a user