diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a4b5e739fada1e9c4612e3c83eb0aeb983d6959f..048e1663ba0e011f121b0480fa895cbc5a65b65a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,19 +1,50 @@ default: image: python:3-slim +variables: + DOCKER_DRIVER: overlay2 + DOCKER_TLS_CERTDIR: "" + APP_VERSION: "beta" + stages: - test + - build - publish - deploy test: stage: test - script: + script: - pip install -r testing_requirements.txt - - nosetests --with-coverage --cover-package=apiserver --cover-xml + - nosetests --with-coverage --cover-package=apiserver artifacts: reports: cobertura: coverage.xml + +build:sites: + cache: {} + stage: build + script: + - pip install -r requirements.txt + - python frontend/createStatic.py + - echo "static web content has been created" + artifacts: + paths: + - site + +pages: + stage: deploy + image: alpine:latest + dependencies: + - build:sites + script: + - mkdir public + - cp -r site/* public/ + - echo "Deployment finished. Missing API server" + artifacts: + paths: + - public + deploy: stage: deploy variables: @@ -24,7 +55,17 @@ deploy: OS_INTERFACE: public script: - echo "Doing nothing for now" - + - pip install python-openstackclient + - openstack image list + # - openstack server create --flavor s1 --image 149a65b5-aeb8-499f-aaa6-ec966bd28dd6 pipeline-inst + # - reassign floating ip + # - login on the new instance pipeline-inst + # - sudo docker network create net #net is the docker internal network.. put it in a Variable? + # - sudo docker-compose up -d + # - docker build --no-cache=true --pull -f ./apiserver/Dockerfile -t api-test . #pull from $CI_REGISTRY + # - sudo docker run --name api-test-cloud --network net -e VIRTUAL_HOST="zam10028.zam.kfa-juelich.de" -e LETSENCRYPT_HOST="zam10028.zam.kfa-juelich.de" -d api-test + # - openstack server destroy pipeline-inst #old + publishgit-do: image: python:3-slim stage: publish @@ -32,10 +73,44 @@ publishgit-do: - tags tags: [stable] script: - - apt-get update - - apt-get install -y git - - git remote set-url gith "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/eflows4hpc/datacatalog.git" - - git remote -v - - git show-ref - - git push gith $CI_COMMIT_REF_NAME + - apt-get update + - apt-get install -y git + - git remote set-url gith "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/eflows4hpc/datacatalog.git" + - git remote -v + - git show-ref + - git push gith $CI_COMMIT_REF_NAME + +# This is an automatic push of the docker image into gitLab container repository +transfer_image: + stage: build + image: docker:19.03.12 + services: + - docker:19.03.12-dind + variables: + IMAGE_COMMIT_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build --no-cache=true --pull -f ./apiserver/Dockerfile -t $IMAGE_COMMIT_TAG . + - docker push $IMAGE_COMMIT_TAG + +tag_release: + stage: publish + needs: ["transfer_image"] + image: docker:19.03.12 + services: + - docker:19.03.12-dind + variables: + IMAGE_LATEST_TAG: $CI_REGISTRY_IMAGE:latest + IMAGE_STABLE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG + IMAGE_COMMIT_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA + only: + - tags + tags: [stable] + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker pull $IMAGE_COMMIT_TAG + - docker tag $IMAGE_COMMIT_TAG $IMAGE_STABLE_TAG + - docker tag $IMAGE_COMMIT_TAG $IMAGE_LATEST_TAG + - docker push $IMAGE_STABLE_TAG + - docker push $IMAGE_LATEST_TAG diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..aec9553b547fcbb0fa26a7619c606f70c9460f2a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,48 @@ +version: "3.7" + +services: + + reverse-proxy: + image: "jwilder/nginx-proxy:latest" + container_name: "reverse-proxy" + volumes: + - "html:/usr/share/nginx/html" + - "dhparam:/etc/nginx/dhparam" + - "vhost:/etc/nginx/vhost.d" + - "certs:/etc/nginx/certs" + - "/run/docker.sock:/tmp/docker.sock:ro" + restart: "always" + networks: + - "net" + ports: + - "80:80" + - "443:443" + + letsencrypt: + image: "jrcs/letsencrypt-nginx-proxy-companion:latest" + container_name: "letsencrypt-helper" + volumes: + - "html:/usr/share/nginx/html" + - "dhparam:/etc/nginx/dhparam" + - "vhost:/etc/nginx/vhost.d" + - "certs:/etc/nginx/certs" + - "/run/docker.sock:/var/run/docker.sock:ro" + environment: + NGINX_PROXY_CONTAINER: "reverse-proxy" + DEFAULT_EMAIL: "m.petrova@fz-juelich.de" + restart: "always" + depends_on: + - "reverse-proxy" + networks: + - "net" + +volumes: + certs: + html: + vhost: + dhparam: + +networks: + net: + external: true + \ No newline at end of file