Commit 54453e32 authored by femiadeyemi's avatar femiadeyemi
Browse files

add env variable to dockerfile and adjust ci/cd deploy stage

Motivation:

Since we are moving to dockerize deployment, some variables,
like the neo4j hostname needs to be set different base on
the environment set up.

Also, we need to seperated the images that will be generated
when a normal commit is made and when a release is trigger.

Modification:

- expose the neo4j host name as configurable variable
- seperate docker image generated from a commit and a tag
    release
- add production_deployment to ci/cd deploy stage. This
   will be use to depoly to the production system. However,
   it just include a test to see if the ssh will work.

Result:

Two different docker images will be build, one for stable
tagged release and the other for development. These images
will be push to different docker repositories.

Target: master
parent b42fd5ec
......@@ -6,7 +6,7 @@ stages:
variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
DOCKER_IMAGE_TAGGED: helmholtzcloudserviceuser/cerebrum:$CI_COMMIT_SHA
DOCKER_IMAGE_TAGGED: helmholtzcloud/cerebrum:$CI_COMMIT_TAG
DOCKER_IMAGE_LATEST: helmholtzcloudserviceuser/cerebrum:latest
cache:
......
......@@ -34,6 +34,7 @@ package:
docker_push:
only:
- master
- tags
stage: deploy
image: docker:19.03.11
services:
......@@ -43,9 +44,30 @@ docker_push:
- docker info
script:
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- docker build -t $DOCKER_IMAGE_LATEST .
- docker push $DOCKER_IMAGE_LATEST
- |-
if [[ $CI_COMMIT_TAG == "" ]]; then
docker build -t $DOCKER_IMAGE_LATEST .
docker push $DOCKER_IMAGE_LATEST
else
docker build -t $DOCKER_IMAGE_TAGGED .
docker push $DOCKER_IMAGE_TAGGED
dependencies:
- package
tags:
- "docker"
production_deployment:
image: ubuntu
only:
- master
stage: deploy
before_script:
- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
script:
- ssh -A ubuntu@hifis-tp.desy.de
- echo $(whoami)
- exit
\ No newline at end of file
FROM adoptopenjdk:11-jre-hotspot
COPY target/helmholtz-cerebrum-*.jar app.jar
ENV NEO4J_ADDRESS localhost
COPY target/helmholtz-cerebrum-*.jar cerebrum.jar
EXPOSE 8090
CMD java -Dspring.profiles.active=dev -jar app.jar -DclientSecret=$CLIENT_SECRET
CMD java -Dspring.profiles.active=dev -jar cerebrum.jar --org.neo4j.driver.uri="bolt://${NEO4J_ADDRESS}:7687"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment