blob: 334dcd511d6b56ab2e54845af25d51fadf004061 [file] [log] [blame]
Marc Kupietz6dd64022023-11-18 21:30:56 +01001stages:
2 - build-and-test
3 - build-docker-image
Marc Kupietz85a4c3d2023-12-19 17:22:37 +01004 - deploy
Marc Kupietz6ac65072023-11-17 20:31:39 +01005
Marc Kupietz6dd64022023-11-18 21:30:56 +01006build-and-test:
7 image: rocker/tidyverse
8 stage: build-and-test
Marc Kupietz6dd64022023-11-18 21:30:56 +01009 before_script:
10 - source `find .. -name section_helper.sh`
Marc Kupietz6ac65072023-11-17 20:31:39 +010011
Marc Kupietz6dd64022023-11-18 21:30:56 +010012 - 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
32build-docker-image:
33 image: docker:latest
Marc Kupietz85a4c3d2023-12-19 17:22:37 +010034 stage: build-docker-image
Marc Kupietz6dd64022023-11-18 21:30:56 +010035 services:
36 - docker:dind
Marc Kupietzf6bb6cb2023-11-18 17:17:50 +010037 rules:
38 - if: $CI_COMMIT_TAG =~ /.+/
39 variables:
40 VID: $CI_COMMIT_TAG
41 - when: manual
42 variables:
Marc Kupietz6dd64022023-11-18 21:30:56 +010043 VID_ALT: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA
44 VID: snapshot
Marc Kupietz6483a9b2023-11-21 16:31:16 +010045 cache:
Marc Kupietzf9ec7672023-11-21 17:54:55 +010046 key: corpuscomposition
Marc Kupietz6483a9b2023-11-21 16:31:16 +010047 paths:
48 - cache/
Marc Kupietz6ac65072023-11-17 20:31:39 +010049 before_script:
Marc Kupietz6483a9b2023-11-21 16:31:16 +010050 - mkdir -p cache
Marc Kupietzf6bb6cb2023-11-18 17:17:50 +010051 - apk update
52 - apk add --no-cache git
Marc Kupietz6ac65072023-11-17 20:31:39 +010053 script:
Marc Kupietz25da3912023-12-05 15:39:00 +010054 - docker rm --force /corpuscomposition
Marc Kupietzf6bb6cb2023-11-18 17:17:50 +010055 - docker build -f Dockerfile -t korap/corpuscomposition:$VID .
Marc Kupietz901a5c12023-11-21 17:54:40 +010056 - docker run -d --name corpuscomposition korap/corpuscomposition:$VID
Marc Kupietz6483a9b2023-11-21 16:31:16 +010057 - docker cp corpuscomposition:/cache ./
58 - docker kill corpuscomposition
Marc Kupietz901a5c12023-11-21 17:54:40 +010059 - 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 Kupietz6483a9b2023-11-21 16:31:16 +010060 - docker save korap/corpuscomposition.slim | xz -T0 > corpuscomposition-$VID.xz
Marc Kupietzf6bb6cb2023-11-18 17:17:50 +010061 artifacts:
62 paths:
63 - corpuscomposition-$VID.xz
64
Marc Kupietz85a4c3d2023-12-19 17:22:37 +010065deploy:
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