add image build to ci / changed db cehcks
Signed-off-by: André Bauer <monotek23@gmail.com>
This commit is contained in:
		
							parent
							
								
									48f34f747b
								
							
						
					
					
						commit
						af8d42b410
					
				
							
								
								
									
										22
									
								
								.github/docker-image-build.sh
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								.github/docker-image-build.sh
									
									
									
									
										vendored
									
									
										Normal 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 | ||||
							
								
								
									
										13
									
								
								.github/workflows/ci.yaml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								.github/workflows/ci.yaml
									
									
									
									
										vendored
									
									
								
							| @ -32,12 +32,25 @@ jobs: | ||||
|         with: | ||||
|           dockerfile: containers/zammad-postgresql/Dockerfile                  | ||||
| 
 | ||||
|   build-containers: | ||||
|     runs-on: ubuntu-latest | ||||
|     env: | ||||
|       DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||||
|       DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||||
|     steps: | ||||
|       - name: Checkout | ||||
|         uses: actions/checkout@v1  | ||||
|       - name: build docker containers | ||||
|         run: .github/docker-image-build.sh | ||||
| 
 | ||||
|   test-docker-compose: | ||||
|     timeout-minutes: 10 | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - name: Checkout | ||||
|         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 | ||||
|         run: docker-compose pull | ||||
|       - name: run docker-compose up | ||||
|  | ||||
| @ -49,36 +49,23 @@ if [ "$1" = 'zammad-init' ]; then | ||||
|   # 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 | ||||
| 
 | ||||
|   echo "initialising / updating database..." | ||||
| 
 | ||||
|   # check if database exists / update to new version | ||||
|   set +e | ||||
|   bundle exec rake db:migrate &> /dev/null | ||||
|   DB_MIGRATE="$?" | ||||
|   echo "initialising / updating database..." | ||||
|   if ! (bundle exec rails r 'puts User.any?' 2> /dev/null | grep -q true); then | ||||
|         if [ "${POSTGRESQL_DB_CREATE}" == "true" ]; then | ||||
|           bundle exec rake db:create | ||||
|         fi | ||||
|         bundle exec rake db:migrate | ||||
|         bundle exec rake db:seed | ||||
| 
 | ||||
|   # 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="$?" | ||||
|         # create autowizard.json on first install | ||||
|         if [ -n "${AUTOWIZARD_JSON}" ]; then | ||||
|           echo "${AUTOWIZARD_JSON}" | base64 -d > auto_wizard.json | ||||
|         fi | ||||
|   else | ||||
|         bundle exec rake db:migrate | ||||
|   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 | ||||
|   fi | ||||
| 
 | ||||
|   # populate database and create autowizard.json on first install | ||||
|   if [ "${DB_SETTINGS}" != "0" ]; then | ||||
|       echo "seeding database..." | ||||
|       bundle exec rake db:seed | ||||
| 
 | ||||
|       if [ -n "${AUTOWIZARD_JSON}" ]; then | ||||
|         echo "${AUTOWIZARD_JSON}" | base64 -d > auto_wizard.json | ||||
|       fi | ||||
|   fi | ||||
| 
 | ||||
|   | ||||
|   # es config | ||||
|   echo "changing settings..." | ||||
|   bundle exec rails r "Setting.set('es_url', '${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}')" | ||||
| @ -116,11 +103,6 @@ fi | ||||
| if [ "$1" = 'zammad-nginx' ]; then | ||||
|   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..." | ||||
| 
 | ||||
|   exec /usr/sbin/nginx -g 'daemon off;' | ||||
|  | ||||
| @ -11,7 +11,7 @@ services: | ||||
|       - BACKUP_SLEEP=86400 | ||||
|       - HOLD_DAYS=10 | ||||
|       - POSTGRESQL_USER=${POSTGRES_USER} | ||||
|       - POSTGRESQL_PASSWORD=${POSTGRES_PASS}     | ||||
|       - POSTGRESQL_PASSWORD=${POSTGRES_PASS} | ||||
|     image: ${IMAGE_REPO}:zammad-postgresql${VERSION} | ||||
|     links: | ||||
|       - zammad-postgresql | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user