Commit fd6cc165 authored by Indrek Jentson's avatar Indrek Jentson

Muudetud CI vajadusele vastavaks

parent ce91b6d9
Pipeline #315 passed with stage
in 6 minutes and 29 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:buster
FROM registry.gitlab.keeleressursid.ee/keeleliin/keeleliin-service-base:latest
# Kui Debianil pole vaikimisi kaasas GCC vajalikke teeke vms, siis tuleb need ka lasta installida.
# Määratleme aktiivse töökataloogi
RUN 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 && \
apt-get -y install git && echo "Installed NODE.JS"
WORKDIR /wrapper
RUN npm install -g forever
# SIIA ALLA lisa kõik installeerimise käsud, mis on vajalikud sisulist tööd tegeva tarkvara X paigaldamiseks.
# Tarkvara X paigaldamine algab
# Valmistame ette koodi, mida me DOCKERis kasutama hakkame. Siinkohal peaks plaanima, et mis failid kus kataloogis peaks olema
RUN git clone https://github.com/Filosoft/vabamorf.git && \
cd vabamorf && \
cd apps/cmdline/project/unix && \
make -f Makefile > make_vabamorf.log && \
apt-get -y install gawk
RUN 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 && \
RUN cd /wrapper/vabamorf && \
JUUR=$(pwd) && \
cd ${JUUR}/dct/sh && \
chmod +x *.sh && \
echo "NPM is installed"
# Määratleme aktiivse töökataloogi
WORKDIR /wrapper
./nullist-uus-sonastik.sh > make_sonastik.log && \
cd /wrapper && \
git clone 'https://github.com/EstSyntax/EstCG.git' && \
apt-get -y install nano
# SIIA ALLA lisa kõik installeerimise käsud, mis on vajalikud sisulist tööd tegeva tarkvara X paigaldamiseks.
# Tarkvara X paigaldamine algab
RUN wget http://apertium.projectjj.com/apt/install-nightly.sh -O - | bash && \
apt-get -y install cg3
COPY config_dist.js /wrapper/config.js
COPY *.sh /wrapper
COPY config_dist.js /wrapper/config_dist.js
COPY command.sh /wrapper
RUN chmod +x command.sh && \
wget http://apertium.projectjj.com/apt/install-nightly.sh -O - | bash && \
apt-get -y install cg3 && \
git clone 'https://github.com/EstSyntax/EstCG.git'
RUN echo "Specific utilities install DONE" && \
chmod +x command.sh
# Tarkvara X paigaldamine lõppeb
# Expose port
EXPOSE 3012
VOLUME ["/config"]
VOLUME ["/wrapper/logs"]
VOLUME ["/wrapper/files"]
VOLUME ["/wrapper/tmp"]
VOLUME ["/config", "/wrapper/logs", "/wrapper/files", "/wrapper/tmp"]
CMD /wrapper/docker_start.sh
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
......@@ -3,4 +3,4 @@ RADA=/wrapper/EstCG
RADAMRF=/wrapper/vabamorf/apps/cmdline/project/unix
RADADCT=/wrapper/vabamorf/dct/binary/
cat $1 | vislcg3 -g $RADA/preprocess.rul | vislcg3 -o -g $RADA/clo.rul | vislcg3 -o -g $RADA/morfyhe.rul
cat $1 | vislcg3 -g $RADA/preprocess.rul | vislcg3 -o -g $RADA/clo.rul | vislcg3 -o -g $RADA/morfyhe17.rul
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
This diff is collapsed.
Markdown is supported
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