Commit 24bd8e50 authored by Indrek Jentson's avatar Indrek Jentson
Browse files

Muudetud vastavaks CI vajadustele

parent 32f67265
Pipeline #314 passed with stage
in 6 minutes and 50 seconds
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
stages:
- build
- deploy
build:
stage: build
only:
- master
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- echo CI_REGISTRY_IMAGE $CI_REGISTRY_IMAGE
- /kaniko/executor --context $CI_PROJECT_DIR --cache --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_BUILD_REF --destination $CI_REGISTRY_IMAGE:latest
# DOCKERi skript
FROM debian:oldstable
# Kui Debianil pole vaikimisi kaasas GCC vajalikke teeke vms, siis tuleb need ka lasta installida.
RUN echo "Default utilities install" && \
apt-get update && \
apt-get -y install curl sudo gnupg apt-utils && \
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash - && \
apt-get -y install build-essential nodejs wget gawk && \
apt-get -y install git && echo "Default utilities installed"
RUN npm install -g forever
# Valmistame ette koodi, mida me DOCKERis kasutama hakkame. Siinkohal peaks plaanima, et mis failid kus kataloogis peaks olema
RUN echo "Wrapper install" && \
git clone 'https://gitlab.keeleressursid.ee/keeleliin/keeleliin-wrapper.git' --single-branch wrapper && \
mkdir -p /config && mkdir -p /wrapper/files && mkdir -p /wrapper/tmp && mkdir -p /wrapper/logs && \
cd wrapper && npm install && \
chmod +x *.sh && \
echo "Wrapper and NPM installed"
FROM registry.gitlab.keeleressursid.ee/keeleliin/keeleliin-service-base:latest
# Määratleme aktiivse töökataloogi
......@@ -29,22 +9,17 @@ WORKDIR /wrapper
# SIIA ALLA lisa kõik installeerimise käsud, mis on vajalikud sisulist tööd tegeva tarkvara X paigaldamiseks.
# Tarkvara X paigaldamine algab
COPY config_dist.js /wrapper/config.js
COPY command.sh /wrapper
RUN echo "Specific utilities install" && \
chmod +x command.sh
RUN git clone https://github.com/Filosoft/vabamorf.git && \
cd vabamorf && \
cd apps/cmdline/project/unix && \
make -f Makefile
make -f Makefile > make_vabamorf.log && \
apt-get -y install gawk
RUN cd /wrapper/vabamorf && \
JUUR=$(pwd) && \
cd ${JUUR}/dct/sh && \
chmod +x *.sh && \
./nullist-uus-sonastik.sh && \
./nullist-uus-sonastik.sh > make_sonastik.log && \
cd /wrapper && \
git clone 'https://github.com/EstSyntax/EstCG.git' && \
apt-get -y install nano
......@@ -55,14 +30,17 @@ COPY EstCGFix/rtolkija.pl /wrapper/EstCG/rtolkija.pl
RUN cd /wrapper/EstCG && \
chmod +x *.pl
COPY config_dist.js /wrapper/config_dist.js
COPY command.sh /wrapper
RUN echo "Specific utilities install DONE" && \
chmod +x command.sh
# Tarkvara X paigaldamine lõppeb
# Expose port
EXPOSE 3011
VOLUME ["/config"]
VOLUME ["/wrapper/logs"]
VOLUME ["/wrapper/files"]
VOLUME ["/wrapper/tmp"]
VOLUME ["/config", "/wrapper/logs", "/wrapper/files", "/wrapper/tmp"]
CMD /wrapper/docker_start.sh
# Teenus KL-MORPH-ANALYSER
Käesolev teenus kasutab Vabamorf käsurea utiliiti ja tagastab etteantava lausestatud tekstifaili kohta
Käesolev teenus kasutab Vabamorf käsurea utiliiti ja tagastab etteantava **lausestatud tekstifaili** kohta
tekstifaili, milles on iga lausestamise käigus eraldi reale asetatud sõne järel read selle sõne
morfoloogilise analüüsi variantidega.
......@@ -9,6 +9,7 @@ morfoloogilise analüüsi variantidega.
* https://gitlab.keeleressursid.ee/keeleliin/keeleliin-master.git
* https://gitlab.keeleressursid.ee/keeleliin/server.git
* https://gitlab.keeleressursid.ee/keeleliin/klient.git
* https://gitlab.keeleressursid.ee/keeleliin/kl-lausestaja.git
* Tee käesolevast projektist enda serveri kettale kloon:
```
$ git clone https://gitlab.keeleressursid.ee/keeleliin/kl-morph-analyser.git
......
NAME=$(grep -Po " id: '\K.*?(?=')" config_dist.js)
echo "Building image for service $NAME"
docker build --no-cache -t $NAME:latest .
\ No newline at end of file
PORT=$(grep -Po 'port: \K.*?(?=,)' config_dist.js)
NAME=$(grep -Po " id: '\K.*?(?=')" config_dist.js)
echo "Running service $NAME on port $PORT"
docker run --name kl_redis -d redis || true
mkdir -p /srv/kl/$NAME/config
mkdir -p /srv/kl/$NAME/logs
mkdir -p /srv/kl/$NAME/files
mkdir -p /srv/kl/$NAME/tmp
docker run --name $NAME -it -d --link kl_redis:redis \
-p $PORT:$PORT \
-v /srv/kl/$NAME/config:/config \
-v /srv/kl/$NAME/logs:/wrapper/logs \
-v /srv/kl/$NAME/files:/wrapper/files \
-v /srv/kl/$NAME/tmp:/wrapper/tmp \
$NAME
NAME=$(grep -Po " id: '\K.*?(?=')" config_dist.js)
echo "Stopping service $NAME"
docker stop $NAME
docker rm $NAME
PORT=$(grep -Po 'port: \K.*?(?=,)' config_dist.js)
NAME=$(grep -Po " id: '\K.*?(?=')" config_dist.js)
echo "Testing service $NAME on port $PORT"
echo "Service description"
curl -I http://127.0.0.1:$PORT > $NAME-test.txt
grep "HTTP/" $NAME-test.txt
echo "Service check"
curl -I http://127.0.0.1:$PORT/api/v1/check > $NAME-test.txt
grep "HTTP/" $NAME-test.txt
echo "Service statistics"
curl -I http://127.0.0.1:$PORT/api/v1/statistics > $NAME-test.txt
grep "HTTP/" $NAME-test.txt
echo "Service config"
curl -I http://127.0.0.1:$PORT/api/v1/service/config > $NAME-test.txt
grep "HTTP/" $NAME-test.txt
echo "Functional test"
cp test/test-input.txt $NAME-test-input.txt
curl --form content=@$NAME-test-input.txt http://127.0.0.1:$PORT/api/v1/service > $NAME-test.txt
echo ""
SID=$(grep -Po '"sessionId":"\K.*?(?=")' $NAME-test.txt)
status=$(grep -Po '"message":"\K.*?(?=")' $NAME-test.txt)
echo "Session $SID - $status"
rm $NAME-test.txt
rm $NAME-test-input.txt
<s>
#
Teenus
KL-Lausestaja
</s>
<s>
Käesolev
teenus
kasutab
Perli
skripti
EstCG/rlausestaja.pl
ja
tagastab
etteantava
tekstifaili
kohta
</s>
<s>
faili
,
milles
on
igal
real
üks
sõne
ning
lause
algust
ja
lõppu
tähistavad
märgendid
`
<s>
`
ja
`
</s>
`
.
</s>
<s>
EstSG
lähtekood
on
pärit
repositooriumist
https://github.com/EstSyntax/EstCG
.
</s>
<s>
Sisendfaili
näide
:
</s>
<s>
```
</s>
<s>
Mitmekesisus
on
elu
vaieldamatu
omapära
.
</s>
<s>
```
</s>
<s>
Väljundfaili
näide
:
</s>
<s>
```
</s>
<s><s>
Mitmekesisus
</s>
<s>
on
</s>
<s>
elu
</s>
<s>
vaieldamatu
</s>
<s>
omapära
</s>
<s>
.
</s>
</s><s>
```
</s>
<s>
##
Komponendi
docker-compose'ga
kasutamise
ettevalmistamine
(
Linuxis
)
</s>
<s>
*
Eeldame
,
et
serveris
on
juba
olemas
järgmised
projektid
:
</s>
<s>
*
https://gitlab.keeleressursid.ee/keeleliin/keeleliin-master.git
</s>
<s>
*
https://gitlab.keeleressursid.ee/keeleliin/server.git
</s>
<s>
*
https://gitlab.keeleressursid.ee/keeleliin/klient.git
</s>
<s>
*
Tee
käesolevast
projektist
enda
serveri
kettale
kloon
:
</s>
<s>
```
</s>
<s>
$
git
clone
https://gitlab.keeleressursid.ee/keeleliin/kl-wc.git
</s>
<s>
```
</s>
<s>
*
Tutvu
saadaoleva
dokumentatsiooniga
ja
kui
vaja
,
siis
tee
projekti
failidesse
vajalikud
muudatused
.
</s>
<s>
Tavaliselt
on
vaja
muuta
faile
</s>
<s>
*
config_dist.js
</s>
<s>
*
Dockerfile
</s>
<s>
*
README.MD
</s>
<s>
*
Salvesta
tehtud
muudatused
</s>
<s>
```
</s>
<s>
$
git
commit
-a
</s>
<s>
```
</s>
<s>
*
Täienda
konfiguratsioonifaili
keeleliin-master/docker-compose.yml
vastavalt
failis
keeleliin-master/README.MD
kirjapandud
juhistele
.
</s>
<s>
Näiteks
antud
teenuse
nimeks
konfiguratsioonis
on
wordcount
.
</s>
<s>
Jälgi
,
et
config.js-is
kirjeldatud
teenuse
port
,
Dockerfile
#Expose
port
ja
docker-compose.yml'is
olev
service.wordcount.port
oleksid
sama
väärtusega
.
</s>
<s>
*
Valmista
ette
teenuse
konteineri
image
:
</s>
<s>
```
</s>
<s>
$
cd
keeleliin-master
</s>
<s>
$
docker-compose
build
wordcount
</s>
<s>
```
</s>
<s>
*
Kui
keeleliini
rakendus
juba
töötab
,
siis
käivita
uue
teenuse
konteiner
nii
:
</s>
<s>
```
</s>
<s>
$
docker-compose
up
-d
wordcount
</s>
<s>
```
</s>
<s>
*
Kui
keeleliini
rakendus
veel
ei
tööta
,
siis
kogu
rakendust
korraga
käivitakse
nii
:
</s>
<s>
```
</s>
<s>
$
docker-compose
up
-d
</s>
<s>
```
</s>
<s>
*
Uue
teenuse
funktsioneerimist
saab
kontrollida
,
kui
pöörduda
veebilehitsejaga
serveri
teenusele
määratud
pordi
poole
.
</s>
<s>
Kui
serveri
nimeks
on
'kl-host'
ja
</s>
<s>
teenuse
pordiks
näiteks
3006
,
siis
peaks
näha
olema
infot
järgmistel
lehtedel
:
</s>
<s>
*
http://kl-host:3006/
</s>
<s>
*
http://kl-host:3006/api/v1/check
</s>
<s>
*
http://kl-host:3006/api/v1/statistics
</s>
<s>
*
http://kl-host:3006/api/v1/service/install
</s>
<s>
*
Soovi
korral
saab
teenuse
konteineris
teha
toiminguid
,
aga
eeldatavasti
ei
ole
vaja
midagi
täiendavat
teha
:
</s>
<s>
```
</s>
<s>
$
docker-compose
exec
wordcount
bash
</s>
<s>
```
</s>
<s>
*
Keeleliini
üksiku
teenuse
(
või
kogu
rakenduse
)
saab
seisma
panna
nii
:
</s>
<s>
```
</s>
<s>
$
docker-compose
down
wordcount
</s>
<s>
$
docker-compose
down
</s>
<s>
```
</s>
Supports Markdown
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