Skip to content
Snippets Groups Projects
Commit f88e5743 authored by Michal Petrovič's avatar Michal Petrovič
Browse files

Update .gitlab-ci.yml file

parent f4dd4c2a
Branches
1 merge request!4Resolve "Vyuzitie cachce miesto artifacts pomocou tags pre runnery"
Pipeline #166545 passed with stages
in 41 seconds
variables: variables:
DOCKER_HOST: $DOCKER_HOST_BIO DOCKER_HOST: $DOCKER_HOST_BIO
PROJECT_NAME: "frontend" PROJECT_NAME: "frontend"
cache: cache:
key: $CI_COMMIT_REF_NAME key: $CI_COMMIT_REF_NAME
paths: paths:
- build/ - build/
stages: stages:
- analyse
- build - build
- publish - test
- deploy - create
- read
# ===========================================================================
# 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
only:
refs:
- main
except:
variables:
- $CI_COMMIT_TAG
before_script:
- mkdir -p build
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: 10 mins # Optional: Set an expiration time for the artifact
docker-build-tag: job1:
stage: build stage: build
image: docker:git tags:
only: - rancher02
variables:
- $CI_COMMIT_TAG
before_script:
- mkdir -p build
script: script:
- docker build -t $DOCKER_NAMESPACE/$PROJECT_NAME:$CI_COMMIT_TAG . - echo "Building on rancher02"
- 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
#
# TODO
# ===========================================================================
# ===========================================================================
# Stage: publish
# ===========================================================================
docker-push-latest: job2:
stage: publish stage: test
image: docker tags:
only: - rancher03
- main
before_script:
- docker login -u $DOCKER_USERNAME -p $DOCKER_TOKEN $DOCKER_REGISTRY
script: script:
- docker load -i build/image.tar - echo "Running tests on a worker runner"
- docker push $DOCKER_NAMESPACE/$PROJECT_NAME:latest
docker-push-tag: create-cache:
stage: publish stage: create
image: docker tags:
only: - cache
variables:
- $CI_COMMIT_TAG
before_script:
- docker login -u $DOCKER_USERNAME -p $DOCKER_TOKEN $DOCKER_REGISTRY
script: script:
- docker load -i build/image.tar - mkdir -p build
- docker push $DOCKER_NAMESPACE/$PROJECT_NAME:$CI_COMMIT_TAG - echo "Hello World" > build/hello.txt
- echo "Cache file created."
# ===========================================================================
# 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: read-cache:
stage: deploy stage: read
only: tags:
variables: - cache
- $CI_COMMIT_TAG
script: script:
- scp .env root@bioinformatics.ibp.cz:/opt/ - if [ -f build/hello.txt ]; then
- scp docker-compose.yml root@bioinformatics.ibp.cz:/opt/ echo "Reading cached file:";
- ssh root@bioinformatics.ibp.cz "cd /opt && export $(xargs < .env) && docker stack deploy dna-analyser -c docker-compose.yml" cat build/hello.txt;
else
echo "Cached file not found.";
fi
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