genericdatabaseapiservice/.gitlab-ci.yml

37 lines
1.5 KiB
YAML

include:
- project: "SharedLibraries/CommonCI/webservices-common-ci"
ref: 3.x
file: "webservices-gitlab-ci-template-dotnetcore.yml"
versionize:
before_script:
- VERSION=`echo -e "import yaml\nwith open('openapi.yaml') as f:d=yaml.load(f)\nprint d['info']['version']" | python`
.deploy:
stage: deploy
image: devnexus.krohne.com:18079/repository/docker-krohne/krohnedockerbash:1.1.0
except:
- tags
artifacts:
paths:
- instance.txt
- api_major_version.txt
- api_version.txt
expire_in: 1 day
needs:
- dockerize
when: manual
allow_failure: false
script:
- echo $INSTANCE_SPECIFIER > instance.txt
- echo -n $API_VERSION > api_version.txt
- echo -n $API_MAJOR_VERSION > api_major_version.txt
- CONTAINER_NAME="${CI_PROJECT_PATH_SLUG}-${INSTANCE_SPECIFIER}-${API_MAJOR_VERSION}"
- SERVICE_PORT=$((SERVICE_FIRST_PORT + SERVICE_PORT_OFFSET + (API_MAJOR_VERSION - 1) % 5))
- echo "Service port is ${SERVICE_PORT}"
- docker stop $CONTAINER_NAME || echo "$CONTAINER_NAME not running, anyway okay"
- docker pull $IMAGE_NAME:$VERSION
- echo "docker run -d --rm -e TZ=Europe/Berlin -p $SERVICE_PORT:$WEBSERVICE_PORT --name $CONTAINER_NAME -e WEBSERVICE_INSTANCE=$INSTANCE_SPECIFIER -e Database__Password=$DATABASE_PASSWORD $IMAGE_NAME:$VERSION" > /start-scripts/${CONTAINER_NAME}.sh
- chmod 755 /start-scripts/${CONTAINER_NAME}.sh
- /start-scripts/${CONTAINER_NAME}.sh