Newer
Older
stages:
- analyse
- build
- publish
- deploy
# ===========================================================================
# Stage: analyse
# ===========================================================================
include:
- template: Code-Quality.gitlab-ci.yml
code_quality:
stage: analyse
services: [] # Shut off Docker-in-Docker
variables:
REPORT_FORMAT: html
artifacts:
paths: [gl-code-quality-report.html]
# second job has to be run to create both artefacts
code_quality_json:
extends: code_quality
variables:
REPORT_FORMAT: json
artifacts:
paths: [gl-code-quality-report.json]
# ===========================================================================
# Stage: build
# ===========================================================================
docker-build-latest:
stage: build
image: docker:git
script:
- docker build -t $DOCKER_NAMESPACE/$PROJECT_NAME:latest .
- docker save -o build/image.tar $DOCKER_NAMESPACE/$PROJECT_NAME:latest
artifacts:
paths:
- build/image.tar
expire_in: 1 hour # Optional: Set an expiration time for the artifact
docker-build-tag:
stage: build
image: docker:git
only:
variables:
- $CI_COMMIT_TAG
script:
- docker build -t $DOCKER_NAMESPACE/$PROJECT_NAME:$CI_COMMIT_TAG .
- docker save -o build/image.tar $DOCKER_NAMESPACE/$PROJECT_NAME:$CI_COMMIT_TAG
artifacts:
paths:
- build/image.tar
expire_in: 10 mins # Optional: Set an expiration time for the artifact
# ===========================================================================
# Stage: test
# ===========================================================================
# ===========================================================================
# Stage: publish
# ===========================================================================
docker-push-latest:
stage: publish
image: docker
script:
- docker load -i build/image.tar
- docker push $DOCKER_NAMESPACE/$PROJECT_NAME:latest
docker-push-tag:
stage: publish
image: docker
only:
variables:
- $CI_COMMIT_TAG
before_script:
script:
- docker load -i build/image.tar
- docker push $DOCKER_NAMESPACE/$PROJECT_NAME:$CI_COMMIT_TAG
# ===========================================================================
# Stage: deploy
# ===========================================================================
deploy-bioinformatika.pef.mendelu.cz:
stage: deploy
only:
- main
script:
- cp .env /home/bioinformatics/
- cd /home/bioinformatics/
- docker-compose config > docker-swarm.yml
# - docker stack deploy -c docker-compose.yml test_stack
# after_script:
# - docker system prune -f
deploy-bioinformatics.ibp.cz:
stage: deploy
only:
variables:
- $CI_COMMIT_TAG
script:
- scp .env root@bioinformatics.ibp.cz:/opt/
- scp docker-compose.yml root@bioinformatics.ibp.cz:/opt/
- ssh root@bioinformatics.ibp.cz "cd /opt && export $(xargs < .env) && docker stack deploy dna-analyser -c docker-compose.yml"