Commit 856f8d15 authored by priit's avatar priit

Dockeri alge

parent ceae0926
......@@ -11,5 +11,5 @@ tmp_tests/94megafile
tmp_tests/189megafile
keeleliin.log
coverage
wrapper_configs/local_global.js
global_config/local_global.js
updateWrappers.sh
\ No newline at end of file
FROM ubuntu:14.04
# docker build -t kl_wrapper .
# docker run --name kl_redis --rm --restart=no redis
# docker run --name kl_wrapper -d -it --link kl_redis:redis -p 3000:3000 -v /config:/config -v /logs:/logs kl_wrapper
# docker kill kl_wrapper
# docker rm kl_wrapper
#
MAINTAINER priit@bitweb.ee
FROM ubuntu:14.04
RUN apt-get update && \
apt-get -y install curl && \
curl -sL https://deb.nodesource.com/setup | sudo bash - && \
apt-get -y install python build-essential nodejs
RUN apt-get update && apt-get -y install nodejs npm git
# Provides cached layer for node_modules
ADD package.json /tmp/package.json
RUN cd /tmp && npm install && npm install -g forever
RUN mkdir -p /src && cp -a /tmp/node_modules /src/
RUN npm install -g forever
# Define working directory
WORKDIR /src
ADD . /src
RUN mkdir -p /src
RUN cd /src && git clone 'https://github.com/BitWeb/keeleliin-wrapper-service.git' . && echo "Git is cloned 1"
RUN cd /src && npm install && echo "NPM is installed 1"
# Expose port
#Expose port
EXPOSE 3000
VOLUME ["/wrapper"]
VOLUME ["/src"]
# Run app using forever
CMD ["forever", "/src/app.js"]
\ No newline at end of file
CMD /./src/docker_start.sh
\ No newline at end of file
var config = require('./wrapper_configs/global');
var config = require('./global_config/global');
//config.serverUrl = 'http://localhost';
//config.redis = {
// host: process.env.REDIS_PORT_6379_TCP_ADDR || "127.0.0.1",
// port: process.env.REDIS_PORT_6379_TCP_PORT || 6379
//};
//config.integration = [
// {
// installUrl: 'http://keeleliin.keeleressursid.ee:3000/api/v1/service/install',
// apiKey: 'server-wrapper-api-key'
// }
//];
//config.fs = {
// storagePath: "/wrapper/files",
// tmpPath: "/wrapper/tmp"
//};
/*config.log4js.appenders.push({
"type": "logLevelFilter",
......@@ -30,10 +50,52 @@ var config = require('./wrapper_configs/global');
}
});*/
config.serverUrl = process.env.SERVER_URL || 'http://dev.bitweb.ee';
config.wrapper = process.env.WRAPPER ? (config.availableWrappers + process.env.WRAPPER) : config.availableWrappers.CONCAT;
config.wrapper = {
id: 'concat', // unikaalne lühinimi
title: 'Lihtne konjateneerija', //Avalik nimi
description: 'Konkateneerib etteantud failid üheks suureks failiks', //Kirjeldus
port: 3000, //port
class: 'simpleLocalCommand', //wrapperi failinimi wrapper kaustast, mida utiliidi käivitamiseks kasutatakse
command: 'cat [data]', // utiliidi käsurea käsk
requestConf: { //Päringu seadistus
requestBodyParamsMappings: {
isAsync: {
type: config.paramTypes.SELECT,
options: ['0', '1'],
value: '1',
usageType: config.paramUsageTypes.META,
filter: function (value) {
return value == 1;
},
required: true,
allowEmpty: false,
validator: function (value, request) {
if( typeof value != 'boolean' ){
request.setMessage('isAsync', 'Peab olema boolean');
return false;
}
return true;
}
}
},
requestFiles: {
content: {
type: 'text',
sizeLimit: 0,
sizeUnit: 'byte',
isList: true
}
}
},
outputTypes: [ //teenuse väljundressursside kirjldused
{
type: 'text',
key: 'output'
}
],
sessionMaxLifetime: 600 // sessiooni maksimaalne kestvus
};
config.fs.storagePath = "/files";
config.fs.tmpPath = "/tmp";
module.exports = config;
\ No newline at end of file
......@@ -13,9 +13,6 @@ router.get('/config', function(req, res) {
router.post('/', function ( req, res ) {
logger.debug(req.body);
logger.debug(req.files);
var serviceRequest = new ServiceRequest( req.body, req.files );
if(!serviceRequest.isValid()){
......@@ -23,6 +20,8 @@ router.post('/', function ( req, res ) {
return;
}
logger.debug(serviceRequest );
wrapperService.execute( serviceRequest, function (err, data) {
if(err) return res.send({errors: err});
res.send(data);
......
#!/bin/bash
if [ ! -f /config/config.js ]; then
cp -R -u -p /src/config_dist.js /config/config.js
fi
if [ ! -f /src/config.js ]; then
ln -s /config/config.js /src/config.js
fi
if [ ! -f /config/wrapper_configs/global.js ]; then
mkdir -p /config/wrapper_configs
ln -s /src/wrapper_configs/global.js /config/wrapper_configs/global.js
cp -R -u -p /src/config_dist.js /src/config.js
fi
forever /src/app.js
\ No newline at end of file
......@@ -44,7 +44,7 @@ function ServiceRequest( requestBody, requestFiles ) {
continue;
}
if(!value){
if(value === null || value === undefined){
value = mapping.value;
}
......
......@@ -13,41 +13,33 @@ function InputOutputLocalCommand(){
var self = this;
this.process = function ( session, callback) {
var contentFile = session.requestFiles.content;
fs.readFile(contentFile, 'utf-8', function (err, sourceText) {
self._getCommandModel(session, function (err, model) {
logger.debug('getCommandModel callback');
if(err) return callback(err);
if(err){
session.setErrors(err);
return callback( err, session );
}
localExecutor.execute( model, session, function ( err, response ) {
self._getCommandModel(session, function (err, model) {
logger.debug('getCommandModel callback');
if(err) return callback(err);
localExecutor.execute( model, session, function ( err, response ) {
if(err) return callback(err);
logger.debug('Program is finished');
if(response.isSuccess){
session.message = Session.messages.OK;
} else {
session.setErrors(response.errors);
}
session.addOutputFile('output', {
type: 'output',
fileName: config.wrapper.id + '_output.' + FileUtil.getExtension( model.outputPaths.output ),
filePath: model.outputPaths.output,
contentType: mime.lookup(model.outputPaths.output)
});
return callback( err, session );
logger.debug('Program is finished');
if(response.isSuccess){
session.message = Session.messages.OK;
} else {
session.setErrors(response.errors);
}
session.addOutputFile('output', {
type: 'output',
fileName: config.wrapper.id + '_output.' + FileUtil.getExtension( model.outputPaths.output ),
filePath: model.outputPaths.output,
contentType: mime.lookup(model.outputPaths.output)
});
return callback( err, session );
});
});
};
this._getCommandModel = function (session, callback) {
......
# docker build -t kl_lausestaja .
#
# docker run --name kl_redis --rm --restart=no redis
#
# docker run --name kl_lausestaja --link kl_redis:redis -p 3001:3001 -v /wrapper/lausestaja/config:/config kl_lausestaja
#
# docker kill kl_lausestaja
#
# docker rm kl_lausestaja
#
#
FROM ubuntu:14.04
ENV TERM xterm
ENV WRAPPER=LAUSESTAJA
ENV SERVER_URL="http://dev.bitweb.ee"
ENV SERVER_PORT=3001
RUN apt-get update && \
apt-get -y install curl && \
curl -sL https://deb.nodesource.com/setup | sudo bash - && \
apt-get -y install python build-essential nodejs && \
apt-get -y install git && \
apt-get -y install unzip
RUN npm install -g forever
RUN mkdir -p /src
RUN mkdir -p /tmp
RUN mkdir -p /files
RUN mkdir -p /logs
RUN mkdir -p /config
RUN cd /src && git clone 'https://github.com/BitWeb/keeleliin-wrapper-service.git' . && npm install && echo "Run is Done"
RUN mkdir /utils
COPY ./utils /utils
RUN unzip /utils/CGParser.zip -d /utils/
RUN unzip /utils/morfyhestaja.zip -d /utils/
RUN chmod 777 -Rf /utils/*
#Expose port
EXPOSE $SERVER_PORT
VOLUME ["/tmp","/files","/logs", "/config"]
CMD /./src/docker_start.sh
\ No newline at end of file
#!/bin/sh
BASEDIR=$(dirname $0)
RADA=$BASEDIR/morfyhestaja/konverter
cat $1 | $RADA/rlausestaja.pl
FROM ubuntu:14.04
MAINTAINER priit@bitweb.ee
RUN apt-get update && \
apt-get -y install curl && \
curl -sL https://deb.nodesource.com/setup | sudo bash - && \
apt-get -y install python build-essential nodejs && \
apt-get -y install git
RUN npm install -g forever
RUN mkdir -p /src
RUN mkdir -p /tmp
RUN mkdir -p /files
RUN mkdir -p /logs
RUN mkdir -p /config
RUN cd /src && git clone 'https://github.com/BitWeb/keeleliin-wrapper-service.git' . && npm install && echo "RunisDon"
// CGParser
// vabamorf
#Expose port
EXPOSE 3000
VOLUME ["/tmp","/files","/logs", "/config"]
CMD /./src/docker_start.sh
\ No newline at end of file
#!/bin/sh
BASEDIR=$(dirname $0)
RADA=$BASEDIR/konverter
RADAMRF=$BASEDIR/vabamorf/apps/cmdline/project/unix
RADADCT=$BASEDIR/vabamorf/dct
cat $1 | $RADA/wr2json.pl | $RADAMRF/etana analyze -lex $RADADCT/et.dct -guess | $RADA/json2mrf.pl
#!/bin/sh
BASEDIR=$(dirname $0)
cd $BASEDIR
cd CGParser
RADA=./
RADAMRF=../vabamorf/apps/cmdline/project/unix
RADADCT=../vabamorf/dct
#Lausestaja
#cat $1 | $RADA/rlausestaja.pl > TMPFILE1
#Morfoloogiline analüüs
#cat TMPFILE1 | $RADA/wr2json.pl | $RADAMRF/etana analyze -lex $RADADCT/et.dct -guess | $RADA/json2mrf.pl > TMPFILE2
#Osalausestamine
#cat TMPFILE2 | $RADA/rtolkija.pl | $RADA/tpron.pl | $RADA/tcopyremover.pl |awk -f $RADA/TTRELLID.AWK | $RADA/tagger09 $RADA/abileksikon06utf.lx stdin stdout | $RADA/tcopyremover.pl | $RADA/tkms2cg3.pl | vislcg3 -o -g $RADA/clo.rul > TMPFILE3
# Morfoloogiline ühestamine (kitsenduste grammatika)
cat $1 | vislcg3 -o -g $RADA/morfyhe.rul
# Pindsüntaktiline analüüs
#cat $1 | vislcg3 -o -g $RADA/PhVerbs.rul | vislcg3 -o -g $RADA/pindsyn.rul
# Sõltuvussüntaktiline analüüs (ja järeltöötlus)
#cat $1 |vislcg3 -o -g $RADA/strukt.rul | $RADA/1reaks.pl | $RADA/inforemover.pl
#!/bin/sh
BASEDIR=$(dirname $0)
cd $BASEDIR
cd CGParser
RADA=./
cat $1 | $RADA/rtolkija.pl | $RADA/tpron.pl | $RADA/tcopyremover.pl |awk -f $RADA/TTRELLID.AWK | $RADA/tagger09 $RADA/abileksikon06utf.lx stdin stdout | $RADA/tcopyremover.pl | $RADA/tkms2cg3.pl | vislcg3 -o -g $RADA/clo.rul
#!/bin/sh
BASEDIR=$(dirname $0)
cd $BASEDIR
cd CGParser
RADA=./
RADAMRF=../vabamorf/apps/cmdline/project/unix
RADADCT=../vabamorf/dct
#Lausestaja
#cat $1 | $RADA/rlausestaja.pl > TMPFILE1
#Morfoloogiline analüüs
#cat TMPFILE1 | $RADA/wr2json.pl | $RADAMRF/etana analyze -lex $RADADCT/et.dct -guess | $RADA/json2mrf.pl > TMPFILE2
#Osalausestamine
#cat TMPFILE2 | $RADA/rtolkija.pl | $RADA/tpron.pl | $RADA/tcopyremover.pl |awk -f $RADA/TTRELLID.AWK | $RADA/tagger09 $RADA/abileksikon06utf.lx stdin stdout | $RADA/tcopyremover.pl | $RADA/tkms2cg3.pl | vislcg3 -o -g $RADA/clo.rul > TMPFILE3
# Morfoloogiline ühestamine (kitsenduste grammatika)
#cat $1 | vislcg3 -o -g $RADA/morfyhe.rul
# Pindsüntaktiline analüüs
cat $1 | vislcg3 -o -g $RADA/PhVerbs.rul | vislcg3 -o -g $RADA/pindsyn.rul
# Sõltuvussüntaktiline analüüs (ja järeltöötlus)
#cat $1 |vislcg3 -o -g $RADA/strukt.rul | $RADA/1reaks.pl | $RADA/inforemover.pl
#!/bin/sh
BASEDIR=$(dirname $0)
cd $BASEDIR
cd CGParser
RADA=./
RADAMRF=../vabamorf/apps/cmdline/project/unix
RADADCT=../vabamorf/dct
#Lausestaja
#cat $1 | $RADA/rlausestaja.pl > TMPFILE1
#Morfoloogiline analüüs
#cat TMPFILE1 | $RADA/wr2json.pl | $RADAMRF/etana analyze -lex $RADADCT/et.dct -guess | $RADA/json2mrf.pl > TMPFILE2
#Osalausestamine
#cat TMPFILE2 | $RADA/rtolkija.pl | $RADA/tpron.pl | $RADA/tcopyremover.pl |awk -f $RADA/TTRELLID.AWK | $RADA/tagger09 $RADA/abileksikon06utf.lx stdin stdout | $RADA/tcopyremover.pl | $RADA/tkms2cg3.pl | vislcg3 -o -g $RADA/clo.rul > TMPFILE3
# Morfoloogiline ühestamine (kitsenduste grammatika)
#cat $1 | vislcg3 -o -g $RADA/morfyhe.rul
# Pindsüntaktiline analüüs
#cat $1 | vislcg3 -o -g $RADA/PhVerbs.rul | vislcg3 -o -g $RADA/pindsyn.rul
# Sõltuvussüntaktiline analüüs (ja järeltöötlus)
cat $1 |vislcg3 -o -g $RADA/strukt.rul | $RADA/1reaks.pl | $RADA/inforemover.pl
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