| stages: |
| - build-and-test |
| - build-docker-image |
| - deploy |
| |
| build-and-test: |
| image: rocker/tidyverse |
| stage: build-and-test |
| before_script: |
| - source `find .. -name section_helper.sh` |
| |
| - start_section install_linux_packages "Installing missing Linux packages" |
| - apt-get update |
| - apt-get install -y libu2f-udev build-essential libglpk40 libcurl4-gnutls-dev libxml2-dev libsodium-dev libsecret-1-dev libfontconfig1-dev libssl-dev libxt6 libpq-dev curl |
| - end_section install_linux_packages |
| |
| - start_section install_r_packages "Installing missing R packages" |
| - R -e "install.packages(c('devtools', 'RKorAPClient', 'httr', 'shiny', 'shinythemes', 'highcharter'))" |
| - R -e 'devtools::install_git("https://korap.ids-mannheim.de/gerrit/IDS-Mannheim/idsThemeR")' |
| - end_section install_r_packages |
| |
| script: |
| - start_section render "Running scripts" |
| - echo 'options(shiny.port=18000)' >> ~/.Rprofile |
| - R_CACHE_ROOTPATH=./cache Rscript shiny/app.R & |
| - PID=$! |
| - sleep 10 |
| - curl http://127.0.0.1:18000/ |
| - kill $PID |
| - end_section render |
| |
| build-docker-image: |
| image: docker:latest |
| stage: build-docker-image |
| services: |
| - docker:dind |
| rules: |
| - if: $CI_COMMIT_TAG =~ /.+/ |
| variables: |
| VID: $CI_COMMIT_TAG |
| - when: manual |
| variables: |
| VID_ALT: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA |
| VID: snapshot |
| cache: |
| key: corpuscomposition |
| paths: |
| - cache/ |
| before_script: |
| - mkdir -p cache |
| - apk update |
| - apk add --no-cache git |
| script: |
| - docker rm --force /corpuscomposition |
| - docker build -f Dockerfile -t korap/corpuscomposition:$VID . |
| - docker run -d --name corpuscomposition korap/corpuscomposition:$VID |
| - docker cp corpuscomposition:/cache ./ |
| - docker kill corpuscomposition |
| - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock dslim/slim build --include-path /usr/local --include-path /cache korap/corpuscomposition |
| - docker save korap/corpuscomposition.slim | xz -T0 > corpuscomposition-$VID.xz |
| artifacts: |
| paths: |
| - corpuscomposition-$VID.xz |
| |
| deploy: |
| image: openjdk:17 |
| stage: deploy |
| dependencies: |
| - build-docker-image |
| rules: |
| - if: $CI_COMMIT_TAG =~ /.+/ |
| variables: |
| VID: $CI_COMMIT_TAG |
| - when: manual |
| variables: |
| VID_ALT: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA |
| VID: snapshot |
| before_script: |
| # - echo `pwd` # debug |
| # - echo "$CI_BUILD_NAME, $CI_BUILD_REF_NAME $CI_BUILD_STAGE" # debug |
| - export GRADLE_USER_HOME=`pwd`/.gradle |
| - microdnf install findutils openssh-clients |
| - eval $(ssh-agent -s) |
| - chmod 400 "$SSH_PRIVATE_KEY" |
| - ssh-add "$SSH_PRIVATE_KEY" |
| - mkdir -p ~/.ssh |
| - chmod 700 ~/.ssh |
| script: |
| - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $DEPLOY_HOST "unxz | docker load" < corpuscomposition-$VID.xz |
| - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $DEPLOY_HOST 'docker kill corpuscomposition && docker run -d --rm --name="corpuscomposition" -p 3838:3838 korap/corpuscomposition.slim' |
| |
| |