Marc Kupietz | 6dd6402 | 2023-11-18 21:30:56 +0100 | [diff] [blame] | 1 | stages: |
| 2 | - build-and-test |
| 3 | - build-docker-image |
Marc Kupietz | 85a4c3d | 2023-12-19 17:22:37 +0100 | [diff] [blame] | 4 | - deploy |
Marc Kupietz | 6ac6507 | 2023-11-17 20:31:39 +0100 | [diff] [blame] | 5 | |
Marc Kupietz | 6dd6402 | 2023-11-18 21:30:56 +0100 | [diff] [blame] | 6 | build-and-test: |
| 7 | image: rocker/tidyverse |
| 8 | stage: build-and-test |
Marc Kupietz | 6dd6402 | 2023-11-18 21:30:56 +0100 | [diff] [blame] | 9 | before_script: |
| 10 | - source `find .. -name section_helper.sh` |
Marc Kupietz | 6ac6507 | 2023-11-17 20:31:39 +0100 | [diff] [blame] | 11 | |
Marc Kupietz | 6dd6402 | 2023-11-18 21:30:56 +0100 | [diff] [blame] | 12 | - start_section install_linux_packages "Installing missing Linux packages" |
| 13 | - apt-get update |
| 14 | - 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 |
| 15 | - end_section install_linux_packages |
| 16 | |
| 17 | - start_section install_r_packages "Installing missing R packages" |
| 18 | - R -e "install.packages(c('devtools', 'RKorAPClient', 'httr', 'shiny', 'shinythemes', 'highcharter'))" |
| 19 | - R -e 'devtools::install_git("https://korap.ids-mannheim.de/gerrit/IDS-Mannheim/idsThemeR")' |
| 20 | - end_section install_r_packages |
| 21 | |
| 22 | script: |
| 23 | - start_section render "Running scripts" |
| 24 | - echo 'options(shiny.port=18000)' >> ~/.Rprofile |
| 25 | - R_CACHE_ROOTPATH=./cache Rscript shiny/app.R & |
| 26 | - PID=$! |
| 27 | - sleep 10 |
| 28 | - curl http://127.0.0.1:18000/ |
| 29 | - kill $PID |
| 30 | - end_section render |
| 31 | |
| 32 | build-docker-image: |
| 33 | image: docker:latest |
Marc Kupietz | 85a4c3d | 2023-12-19 17:22:37 +0100 | [diff] [blame] | 34 | stage: build-docker-image |
Marc Kupietz | 6dd6402 | 2023-11-18 21:30:56 +0100 | [diff] [blame] | 35 | services: |
| 36 | - docker:dind |
Marc Kupietz | f6bb6cb | 2023-11-18 17:17:50 +0100 | [diff] [blame] | 37 | rules: |
| 38 | - if: $CI_COMMIT_TAG =~ /.+/ |
| 39 | variables: |
| 40 | VID: $CI_COMMIT_TAG |
| 41 | - when: manual |
| 42 | variables: |
Marc Kupietz | 6dd6402 | 2023-11-18 21:30:56 +0100 | [diff] [blame] | 43 | VID_ALT: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA |
| 44 | VID: snapshot |
Marc Kupietz | 6483a9b | 2023-11-21 16:31:16 +0100 | [diff] [blame] | 45 | cache: |
Marc Kupietz | f9ec767 | 2023-11-21 17:54:55 +0100 | [diff] [blame] | 46 | key: corpuscomposition |
Marc Kupietz | 6483a9b | 2023-11-21 16:31:16 +0100 | [diff] [blame] | 47 | paths: |
| 48 | - cache/ |
Marc Kupietz | 6ac6507 | 2023-11-17 20:31:39 +0100 | [diff] [blame] | 49 | before_script: |
Marc Kupietz | 6483a9b | 2023-11-21 16:31:16 +0100 | [diff] [blame] | 50 | - mkdir -p cache |
Marc Kupietz | f6bb6cb | 2023-11-18 17:17:50 +0100 | [diff] [blame] | 51 | - apk update |
| 52 | - apk add --no-cache git |
Marc Kupietz | 6ac6507 | 2023-11-17 20:31:39 +0100 | [diff] [blame] | 53 | script: |
Marc Kupietz | 25da391 | 2023-12-05 15:39:00 +0100 | [diff] [blame] | 54 | - docker rm --force /corpuscomposition |
Marc Kupietz | f6bb6cb | 2023-11-18 17:17:50 +0100 | [diff] [blame] | 55 | - docker build -f Dockerfile -t korap/corpuscomposition:$VID . |
Marc Kupietz | 901a5c1 | 2023-11-21 17:54:40 +0100 | [diff] [blame] | 56 | - docker run -d --name corpuscomposition korap/corpuscomposition:$VID |
Marc Kupietz | 6483a9b | 2023-11-21 16:31:16 +0100 | [diff] [blame] | 57 | - docker cp corpuscomposition:/cache ./ |
| 58 | - docker kill corpuscomposition |
Marc Kupietz | 901a5c1 | 2023-11-21 17:54:40 +0100 | [diff] [blame] | 59 | - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock dslim/slim build --include-path /usr/local --include-path /cache korap/corpuscomposition |
Marc Kupietz | 6483a9b | 2023-11-21 16:31:16 +0100 | [diff] [blame] | 60 | - docker save korap/corpuscomposition.slim | xz -T0 > corpuscomposition-$VID.xz |
Marc Kupietz | f6bb6cb | 2023-11-18 17:17:50 +0100 | [diff] [blame] | 61 | artifacts: |
| 62 | paths: |
| 63 | - corpuscomposition-$VID.xz |
| 64 | |
Marc Kupietz | 85a4c3d | 2023-12-19 17:22:37 +0100 | [diff] [blame] | 65 | deploy: |
| 66 | image: openjdk:17 |
| 67 | stage: deploy |
| 68 | dependencies: |
| 69 | - build-docker-image |
| 70 | rules: |
| 71 | - if: $CI_COMMIT_TAG =~ /.+/ |
| 72 | variables: |
| 73 | VID: $CI_COMMIT_TAG |
| 74 | - when: manual |
| 75 | variables: |
| 76 | VID_ALT: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA |
| 77 | VID: snapshot |
| 78 | before_script: |
| 79 | # - echo `pwd` # debug |
| 80 | # - echo "$CI_BUILD_NAME, $CI_BUILD_REF_NAME $CI_BUILD_STAGE" # debug |
| 81 | - export GRADLE_USER_HOME=`pwd`/.gradle |
| 82 | - microdnf install findutils openssh-clients |
| 83 | - eval $(ssh-agent -s) |
| 84 | - chmod 400 "$SSH_PRIVATE_KEY" |
| 85 | - ssh-add "$SSH_PRIVATE_KEY" |
| 86 | - mkdir -p ~/.ssh |
| 87 | - chmod 700 ~/.ssh |
| 88 | script: |
| 89 | - ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $DEPLOY_HOST "unxz | docker load" < corpuscomposition-$VID.xz |
| 90 | - 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' |
| 91 | |
| 92 | |