Skip to content
Snippets Groups Projects
Commit d5886aa7 authored by Eike Cochu's avatar Eike Cochu
Browse files

updated docker config, fixed saving topic model to file on restore

parent 68b73946
No related branches found
No related tags found
No related merge requests found
Showing with 109 additions and 64 deletions
...@@ -13,11 +13,14 @@ This application was created by Eike Cochu for his master's degree thesis in com ...@@ -13,11 +13,14 @@ This application was created by Eike Cochu for his master's degree thesis in com
## Installation ## Installation
1. If MongoDB or ElasticSearch run on different servers that the JavaEE application server, then the configuration files need to be changed. Change `config.properties` file 1. Deploy vipra.war or exploded vipra directory to a Java application server. Deploy to ROOT (/) or a different context path (/vipra, ...)
1. in `vipra.war`: Open `vipra.war` in an archive program, navigate to `/WEB-INF/classes` and edit `config.properties` file appropriately. 2. Edit WEB-INF/classes/config.json if MongoDB or ElasticSearch do not run with default configuration (host/port)
2. in `vipra-cmd.jar`: Open `vipra-cmd.jar` and edit `config.properties` file appropriately. 3. Deploy vipra-ui to a static webserver
3. Test connection by running `./vipra -t` 4. Create rewrite rules to rewrite all non-matching files to /index.html
2. Copy `vipra.war` to your JavaEE application server 5. If not deployed in root, change /index.html <base> tag to context path
6. Change /js/config.js if the backend was not deployed on the same server, not in root context or if the server has a different port than 8080
if everything is left default, application should be available under: http://someserver/ and backend: http://someserver:8080/rest/
## Development ## Development
......
#!/bin/bash
INCLUDE_FRONTEND_IN_WAR=1
# enable/disable (1/0) project building
BUILD_DTM=1
BUILD_VIPRA_UTIL=1
BUILD_VIPRA_CMD=1
BUILD_VIPRA_UI=1
BUILD_VIPRA_BACKEND=1
\ No newline at end of file
#!/bin/sh #!/bin/bash
# point this folder to the webapps dir of your tomcat server for auto deploy source ./build-config.sh
TOMCAT_WEBAPPS="vm/webapps"
# enable/disable (1/0) project building
BUILD_DTM=1
BUILD_VIPRA_UTIL=1
BUILD_VIPRA_CMD=1
BUILD_VIPRA_UI=1
BUILD_VIPRA_BACKEND=1
# enable to deploy frontend assets in vipra.war
# disable if you want to serve frontend assets from another server
INCLUDE_FRONTEND_IN_WAR=1
# ========================================================= # =========================================================
# DO NOT EDIT AFTER THIS POINT # DO NOT EDIT AFTER THIS POINT
...@@ -139,18 +127,5 @@ else ...@@ -139,18 +127,5 @@ else
fi fi
fi fi
# deploy backend war
VIPRA_WAR="vipra-backend/target/vipra.war"
echo "" >> $LOG
echo "-------------------------------" >> $LOG
if [ -d $TOMCAT_WEBAPPS ] && [ -f $VIPRA_WAR ]; then
echo "deploying vipra-backend" | tee -a $LOG
cp $VIPRA_WAR $TOMCAT_WEBAPPS
else
echo "deploying vipra-backend > skipped" | tee -a $LOG
fi
echo "complete" echo "complete"
exit $? exit $?
...@@ -3,11 +3,13 @@ MAINTAINER Eike Cochu <eike@cochu.com> ...@@ -3,11 +3,13 @@ MAINTAINER Eike Cochu <eike@cochu.com>
ENV ES_VERSION 2.3.1 ENV ES_VERSION 2.3.1
ENV TOMCAT_MAJOR 8 ENV TOMCAT_MAJOR 8
ENV TOMCAT_VERSION 8.0.33 ENV TOMCAT_VERSION 8.0.33
RUN apt-get update && \ RUN echo "deb http://ppa.launchpad.net/nginx/stable/ubuntu wily main" >> /etc/apt/sources.list && \
apt-get install -y wget nano openjdk-8-jdk mongodb supervisor && \ apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C && \
apt-get update && \
apt-get install -y --no-install-recommends wget nano openjdk-8-jdk mongodb supervisor nginx && \
apt-get clean && \ apt-get clean && \
rm -rf /var/lib/apt/lists/* && \ rm -rf /var/lib/apt/lists/* && \
mkdir -p /var/log/supervisor /data/db && \ mkdir -p /webroot /var/log/supervisor /data/db && \
wget --no-check-certificate -O- https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/$ES_VERSION/elasticsearch-$ES_VERSION.tar.gz | tar xvfz - && \ wget --no-check-certificate -O- https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/$ES_VERSION/elasticsearch-$ES_VERSION.tar.gz | tar xvfz - && \
mv elasticsearch-$ES_VERSION elasticsearch && \ mv elasticsearch-$ES_VERSION elasticsearch && \
wget -O- http://apache.openmirror.de/tomcat/tomcat-$TOMCAT_MAJOR/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz | tar xvfz - && \ wget -O- http://apache.openmirror.de/tomcat/tomcat-$TOMCAT_MAJOR/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz | tar xvfz - && \
...@@ -15,6 +17,6 @@ RUN apt-get update && \ ...@@ -15,6 +17,6 @@ RUN apt-get update && \
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY tomcat-users.xml /tomcat/conf/tomcat-users.xml COPY tomcat-users.xml /tomcat/conf/tomcat-users.xml
COPY elasticsearch.yml /elasticsearch/config/elasticsearch.yml COPY elasticsearch.yml /elasticsearch/config/elasticsearch.yml
COPY vipra.war /tomcat/webapps/vipra.war COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 8080 9200 9300 27017 EXPOSE 80 8080 9200 9300 27017
CMD ["/usr/bin/supervisord"] CMD ["/usr/bin/supervisord"]
\ No newline at end of file
#!/bin/sh #!/bin/sh
VIPRA_WAR="../vipra-backend/target/vipra.war"
if [ ! -f $VIPRA_WAR ]; then
echo "vipra.war not found. Did you run build.sh?"
exit 1
fi
cp $VIPRA_WAR .
docker build -t eikecochu/vipra . docker build -t eikecochu/vipra .
rm vipra.war
exit 0 exit 0
\ No newline at end of file
#!/bin/sh #!/bin/sh
HOST_NGINX=80
HOST_TOMCAT=8080 HOST_TOMCAT=8080
HOST_ELASTICSEARCH_REST=9200 HOST_ELASTICSEARCH_REST=9200
HOST_ELASTICSEARCH_API=9300 HOST_ELASTICSEARCH_API=9300
HOST_MONGODB=27017 HOST_MONGODB=27017
docker run -d -p $HOST_TOMCAT:8080 -p $HOST_ELASTICSEARCH_REST:9200 -p $HOST_ELASTICSEARCH_API:9300 -p $HOST_MONGODB:27017 eikecochu/vipra DIR="$(dirname "$(readlink -f "$0")")"
\ No newline at end of file
docker run -d -p $HOST_NGINX:80 -p $HOST_TOMCAT:8080 -p $HOST_ELASTICSEARCH_REST:9200 -p $HOST_ELASTICSEARCH_API:9300 -p $HOST_MONGODB:27017 -v $DIR/webroot:/webroot -v $DIR/webapps:/tomcat/webapps eikecochu/vipra
\ No newline at end of file
...@@ -16,4 +16,9 @@ environment=CATALINA_HOME="/tomcat",CATALINA_BASE="/tomcat",CATALINA_TMPDIR="/to ...@@ -16,4 +16,9 @@ environment=CATALINA_HOME="/tomcat",CATALINA_BASE="/tomcat",CATALINA_TMPDIR="/to
command=/tomcat/bin/catalina.sh run command=/tomcat/bin/catalina.sh run
autostart=true autostart=true
autorestart=true autorestart=true
startsecs=10 startsecs=10
\ No newline at end of file
[program:nginx]
command=/usr/sbin/nginx
autostart=true
autorestart=true
\ No newline at end of file
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"> version="3.1">
<welcome-file-list>
<welcome-file>public/index.html</welcome-file>
</welcome-file-list>
<servlet> <servlet>
<servlet-name>jersey</servlet-name> <servlet-name>jersey</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</listAttribute> </listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/> <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="de.vipra.cmd.Main"/> <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="de.vipra.cmd.Main"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-S test -M"/> <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-C yearly"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="vipra-cmd"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="vipra-cmd"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/> <stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea"/> <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea"/>
......
package de.vipra.cmd.option; package de.vipra.cmd.option;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;
import de.vipra.util.Config; import de.vipra.util.Config;
import de.vipra.util.ConsoleUtils; import de.vipra.util.ConsoleUtils;
import de.vipra.util.Constants.ProcessorMode; import de.vipra.util.Constants.ProcessorMode;
import de.vipra.util.Constants.WindowResolution; import de.vipra.util.Constants.WindowResolution;
import de.vipra.util.ex.ConfigException;
import de.vipra.util.ex.DatabaseException; import de.vipra.util.ex.DatabaseException;
import de.vipra.util.model.TopicModelConfig; import de.vipra.util.model.TopicModelConfig;
import de.vipra.util.model.TopicModelFull; import de.vipra.util.model.TopicModelFull;
...@@ -12,13 +18,15 @@ import de.vipra.util.service.MongoService; ...@@ -12,13 +18,15 @@ import de.vipra.util.service.MongoService;
public class EditModelCommand implements Command { public class EditModelCommand implements Command {
private final String[] names; private final String[] names;
private Config config;
private MongoService<TopicModelFull, String> dbTopicModels; private MongoService<TopicModelFull, String> dbTopicModels;
public EditModelCommand(final String[] names) { public EditModelCommand(final String[] names) {
this.names = names; this.names = names;
} }
private void editModel(final TopicModelConfig topicModelConfig) throws DatabaseException { private void editModel(final TopicModelConfig topicModelConfig)
throws DatabaseException, JsonGenerationException, JsonMappingException, IOException, ConfigException {
ConsoleUtils.info("editing model: " + topicModelConfig.getName()); ConsoleUtils.info("editing model: " + topicModelConfig.getName());
topicModelConfig.setDescription(ConsoleUtils.readString("description (↲ to skip)", topicModelConfig.getDescription(), true)); topicModelConfig.setDescription(ConsoleUtils.readString("description (↲ to skip)", topicModelConfig.getDescription(), true));
topicModelConfig.setkTopics(ConsoleUtils.readInt("k topics", topicModelConfig.getkTopics(), 1, null, true)); topicModelConfig.setkTopics(ConsoleUtils.readInt("k topics", topicModelConfig.getkTopics(), 1, null, true));
...@@ -50,11 +58,12 @@ public class EditModelCommand implements Command { ...@@ -50,11 +58,12 @@ public class EditModelCommand implements Command {
final TopicModelFull topicModel = new TopicModelFull(topicModelConfig.getName()); final TopicModelFull topicModel = new TopicModelFull(topicModelConfig.getName());
topicModel.setModelConfig(topicModelConfig); topicModel.setModelConfig(topicModelConfig);
dbTopicModels.updateSingle(topicModel, "modelConfig"); dbTopicModels.updateSingle(topicModel, "modelConfig");
topicModelConfig.saveToFile(topicModelConfig.getModelDir(config.getDataDirectory()));
} }
@Override @Override
public void run() throws Exception { public void run() throws Exception {
final Config config = Config.getConfig(); config = Config.getConfig();
dbTopicModels = MongoService.getDatabaseService(config, TopicModelFull.class); dbTopicModels = MongoService.getDatabaseService(config, TopicModelFull.class);
for (final String name : names) { for (final String name : names) {
......
# Vipra UI # Vipra UI
The frontend UI project. The frontend UI project. Built with AngularJS and many other Javascript and CSS frameworks and libraries:
\ No newline at end of file
* [AngularJS](https://github.com/angular/angular.js) by Google (MIT)
* [Angular Hotkeys](https://github.com/chieffancypants/angular-hotkeys) by Wes Cruver (MIT)
* [AngularUI Router](https://github.com/angular-ui/ui-router) by The AngularUI Team, Karsten Sperling (MIT)
* [jQuery](https://github.com/jquery/jquery) by the jQuery Foundation and other contributors (MIT)
* [Bootstrap](https://github.com/twbs/bootstrap) by Twitter (MIT)
* [bootstrap-datetimepicker](https://github.com/Eonasdan/bootstrap-datetimepicker) by Jonathan Peterson (MIT)
* [nya-bootstrap-select](https://github.com/lordfriend/nya-bootstrap-select) by Nyasoft (MIT)
* [Bootbox.js](https://github.com/makeusabrew/bootbox) by Nick Payne (MIT)
* [Highcharts](http://www.highcharts.com/) by Highsoft (CC-BY-NC)
* [vis.js](https://github.com/almende/vis) by Almende B.V. (MIT)
* [Moment.js](https://github.com/moment/moment) by Tim Wood, Iskren Chernev, Moment.js contributors (MIT)
* [randomColor](https://github.com/davidmerfield/randomColor) by David Merfield (CC0 1.0)
* [FontAwesome](https://github.com/FortAwesome/Font-Awesome) by Dave Gandy (SIL OFL 1.1/MIT)
* [Bower](https://github.com/bower/bower) by Twitter and other contributors (MIT)
* [Gulp](https://github.com/gulpjs/gulp) by Fractal (MIT)
* [gulp-less](https://github.com/plus3network/gulp-less) by Plus 3 Network (MIT)
* [gulp-concat](https://github.com/contra/gulp-concat) by Fractal (MIT)
* [gulp-uglify](https://github.com/terinjokes/gulp-uglify) by Terin Stock (MIT)
* [gulp-clean-css](https://github.com/scniro/gulp-clean-css) by scniro (MIT)
* [gulp-webserver](https://github.com/schickling/gulp-webserver) by Johannes Schickling (MIT)
* [gulp-ng-annotate](https://github.com/Kagami/gulp-ng-annotate) by Kagami Hiiragi and contributors (CC0 1.0)
* [gulp-templatecache](https://github.com/miickel/gulp-angular-templatecache) by Mickel (MIT)
## Installation
### Base path
Simply put all files into a static web server document root.
If the application is not deployed into a web root (/), change the base tag in the file `index.html`
```html
<base href="/somepath" />
```
the href value has to be the same under which the application should be available, e.g. http://someserver/somepath/index.html.
### Backend connection
The backend is expected to be deployed to a Java application server. To change the default REST URL, edit the file `js/config.js`
\ No newline at end of file
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
<link href="css/app.css" rel="stylesheet"> <link href="css/app.css" rel="stylesheet">
<!-- javascript --> <!-- javascript -->
<script src="js/vendor.js"></script> <script src="js/vendor.js"></script>
<script src="js/config.js"></script>
<script src="js/app.js"></script> <script src="js/app.js"></script>
<script src="js/templates.js"></script> <script src="js/templates.js"></script>
</head> </head>
......
...@@ -10,7 +10,16 @@ ...@@ -10,7 +10,16 @@
window.Vipra = window.Vipra || {}; window.Vipra = window.Vipra || {};
Vipra.config = { Vipra.config = {
restUrl: '/vipra/rest' /*
* Point this URL to the backend REST servlet. The default is /rest, which expects the servlet
* to be deployed in the root context. If the servlet is deployed under another context, prepend
* it to this URL. Test the URL by entering this into a browser:
*
* http://yourserver[/rest]/application.wadl
* ^^^^^
* this is the restUrl
*/
restUrl: '//' + location.hostname + ':8080/rest'
}; };
})(); })();
\ No newline at end of file
...@@ -52,18 +52,20 @@ gulp.task('less', function() { ...@@ -52,18 +52,20 @@ gulp.task('less', function() {
}); });
gulp.task('js', function() { gulp.task('js', function() {
gulp.src('app/js/**/*.js') gulp.src(['app/js/**/*.js', '!app/js/config.js'])
.pipe(concat('app.js')) .pipe(concat('app.js'))
.pipe(ngannotate()) .pipe(ngannotate())
//.pipe(uglify()) .pipe(gulp.dest('public/js'));
gulp.src('app/js/config.js')
.pipe(gulp.dest('public/js')); .pipe(gulp.dest('public/js'));
}); });
gulp.task('js-rel', function() { gulp.task('js-rel', function() {
gulp.src(['app/js/**/*.js', '!app/js/dev.js']) gulp.src(['app/js/**/*.js', '!app/js/config.js', '!app/js/dev.js'])
.pipe(concat('app.js')) .pipe(concat('app.js'))
.pipe(ngannotate()) .pipe(ngannotate())
//.pipe(uglify()) .pipe(gulp.dest('public/js'));
gulp.src('app/js/config.js')
.pipe(gulp.dest('public/js')); .pipe(gulp.dest('public/js'));
}); });
......
package de.vipra.util.model; package de.vipra.util.model;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
...@@ -231,9 +230,9 @@ public class TopicModelConfig implements Serializable { ...@@ -231,9 +230,9 @@ public class TopicModelConfig implements Serializable {
public static TopicModelConfig readFromFile(final File modelDir) throws JsonParseException, JsonMappingException, IOException { public static TopicModelConfig readFromFile(final File modelDir) throws JsonParseException, JsonMappingException, IOException {
final File file = new File(modelDir, FILE_NAME); final File file = new File(modelDir, FILE_NAME);
if (!file.exists()) if (file.exists())
throw new FileNotFoundException(file.getAbsolutePath()); return Config.mapper.readValue(file, TopicModelConfig.class);
return Config.mapper.readValue(file, TopicModelConfig.class); return new TopicModelConfig();
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment