Marc Kupietz | 6dd6402 | 2023-11-18 21:30:56 +0100 | [diff] [blame] | 1 | stages: |
| 2 | - build-and-test |
| 3 | - build-docker-image |
Marc Kupietz | 6ac6507 | 2023-11-17 20:31:39 +0100 | [diff] [blame] | 4 | |
Marc Kupietz | 6dd6402 | 2023-11-18 21:30:56 +0100 | [diff] [blame] | 5 | build-and-test: |
| 6 | image: rocker/tidyverse |
| 7 | stage: build-and-test |
| 8 | cache: |
| 9 | key: korap |
| 10 | paths: |
| 11 | - ./cache |
| 12 | before_script: |
| 13 | - source `find .. -name section_helper.sh` |
Marc Kupietz | 6ac6507 | 2023-11-17 20:31:39 +0100 | [diff] [blame] | 14 | |
Marc Kupietz | 6dd6402 | 2023-11-18 21:30:56 +0100 | [diff] [blame] | 15 | - start_section install_linux_packages "Installing missing Linux packages" |
| 16 | - apt-get update |
| 17 | - 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 |
| 18 | - end_section install_linux_packages |
| 19 | |
| 20 | - start_section install_r_packages "Installing missing R packages" |
| 21 | - R -e "install.packages(c('devtools', 'RKorAPClient', 'httr', 'shiny', 'shinythemes', 'highcharter'))" |
| 22 | - R -e 'devtools::install_git("https://korap.ids-mannheim.de/gerrit/IDS-Mannheim/idsThemeR")' |
| 23 | - end_section install_r_packages |
| 24 | |
| 25 | script: |
| 26 | - start_section render "Running scripts" |
| 27 | - echo 'options(shiny.port=18000)' >> ~/.Rprofile |
| 28 | - R_CACHE_ROOTPATH=./cache Rscript shiny/app.R & |
| 29 | - PID=$! |
| 30 | - sleep 10 |
| 31 | - curl http://127.0.0.1:18000/ |
| 32 | - kill $PID |
| 33 | - end_section render |
| 34 | |
| 35 | build-docker-image: |
| 36 | image: docker:latest |
| 37 | services: |
| 38 | - docker:dind |
Marc Kupietz | f6bb6cb | 2023-11-18 17:17:50 +0100 | [diff] [blame] | 39 | rules: |
| 40 | - if: $CI_COMMIT_TAG =~ /.+/ |
| 41 | variables: |
| 42 | VID: $CI_COMMIT_TAG |
| 43 | - when: manual |
| 44 | variables: |
Marc Kupietz | 6dd6402 | 2023-11-18 21:30:56 +0100 | [diff] [blame] | 45 | VID_ALT: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA |
| 46 | VID: snapshot |
| 47 | stage: build-docker-image |
Marc Kupietz | 6483a9b | 2023-11-21 16:31:16 +0100 | [diff] [blame] | 48 | cache: |
| 49 | key: korap |
| 50 | paths: |
| 51 | - cache/ |
Marc Kupietz | 6ac6507 | 2023-11-17 20:31:39 +0100 | [diff] [blame] | 52 | before_script: |
Marc Kupietz | 6483a9b | 2023-11-21 16:31:16 +0100 | [diff] [blame] | 53 | - mkdir -p cache |
Marc Kupietz | f6bb6cb | 2023-11-18 17:17:50 +0100 | [diff] [blame] | 54 | - apk update |
| 55 | - apk add --no-cache git |
Marc Kupietz | 6ac6507 | 2023-11-17 20:31:39 +0100 | [diff] [blame] | 56 | script: |
Marc Kupietz | f6bb6cb | 2023-11-18 17:17:50 +0100 | [diff] [blame] | 57 | - docker build -f Dockerfile -t korap/corpuscomposition:$VID . |
Marc Kupietz | 901a5c1 | 2023-11-21 17:54:40 +0100 | [diff] [blame^] | 58 | - docker run -d --name corpuscomposition korap/corpuscomposition:$VID |
Marc Kupietz | 6483a9b | 2023-11-21 16:31:16 +0100 | [diff] [blame] | 59 | - docker cp corpuscomposition:/cache ./ |
| 60 | - docker kill corpuscomposition |
Marc Kupietz | 901a5c1 | 2023-11-21 17:54:40 +0100 | [diff] [blame^] | 61 | - 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] | 62 | - docker save korap/corpuscomposition.slim | xz -T0 > corpuscomposition-$VID.xz |
Marc Kupietz | f6bb6cb | 2023-11-18 17:17:50 +0100 | [diff] [blame] | 63 | artifacts: |
| 64 | paths: |
| 65 | - corpuscomposition-$VID.xz |
| 66 | |