Skip to content

Commit

Permalink
Docker packaging. New version v0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
KMax committed Mar 30, 2017
1 parent 82b9965 commit 217cdd6
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 21 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
nb-configuration.xml
/target/
**/target
**/tests
**/database
**/.idea
**/*.iml
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM openjdk:8-jre

WORKDIR /home/root

ENV TOMCAT_VERSION=7.0.76 \
TOMCAT_MAJOR_VERSION=7 \
DROOLS_TESTER_VERSION=0.0.3 \
DROOLS_TESTER_TESTS=/home/root/tests

RUN apt-get update && \
apt-get -y install unzip

ADD http://apache-mirror.rbc.ru/pub/apache/tomcat/tomcat-${TOMCAT_MAJOR_VERSION}/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.zip apache-tomcat.zip

RUN unzip apache-tomcat.zip && \
mv apache-tomcat-${TOMCAT_VERSION} apache-tomcat && \
rm -rf apache-tomcat/webapps/ROOT && \
chmod 777 -R apache-tomcat

RUN echo "drools.tester.tests=${DROOLS_TESTER_TESTS}" >> apache-tomcat/conf/catalina.properties

ADD https://github.com/ailabitmo/drools-tester/releases/download/v${DROOLS_TESTER_VERSION}/drools-tester-v${DROOLS_TESTER_VERSION}.war apache-tomcat/webapps/ROOT.war

# For development
#ADD target/drools-tester-v${DROOLS_TESTER_VERSION}.war apache-tomcat/webapps/ROOT.war

CMD apache-tomcat/bin/startup.sh && tail -f apache-tomcat/logs/catalina.out
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: "2"
services:
drools-tester:
image: kolchinmax/drools-tester
links:
- mysql
ports:
- "80:8080"
volumes:
- "./tests:/home/root/tests"
mysql:
image: mysql
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
volumes:
- "./database:/var/lib/mysql"
environment:
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
MYSQL_DATABASE: 'dt-db'
MYSQL_USER: 'dt-user'
MYSQL_PASSWORD: 'dt-password'
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>ru.ifmo.ailab</groupId>
<artifactId>drools-tester</artifactId>
<version>v0.0.2</version>
<version>v0.0.3</version>
<packaging>war</packaging>

<name>drools-tester</name>
Expand Down Expand Up @@ -89,7 +89,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.26</version>
<version>6.0.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public Response upload(@FormDataParam("assignment-number") String assignment,
try {
if (!runnerFactory.isTestsExist(assignment)) {
logger.error("There are no tests for {}! Tried to find at {}",
assignment, runnerFactory.getTestsAssigmentLocation(assignment));
assignment, runnerFactory.getTestsAssignmentLocation(assignment));
return Response.status(Response.Status.BAD_REQUEST).build();
}
if (!ServiceHelper.isValidEmail(email)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TestRunnerFactory {

Expand All @@ -33,17 +35,17 @@ private File getTestsRootLocation() {
}
return new File(location);
}
public File getTestsAssigmentLocation(final String assigment) {
return new File(getTestsRootLocation(), assigment);

public File getTestsAssignmentLocation(final String assignment) {
return new File(getTestsRootLocation(), assignment);
}

public int getNumberOfTests() {
return getTestsRootLocation().list(new AssigmentFilter()).length;
return getTestsRootLocation().list(new AssignmentFilter()).length;
}
private static class AssigmentFilter implements FilenameFilter {

private static class AssignmentFilter implements FilenameFilter {

@Override
public boolean accept(File file, String string) {
return string.matches("assignment-\\d+");
Expand Down Expand Up @@ -80,7 +82,7 @@ private Map<String, JSONObject> readScenarios(final File root)
}
try {
reader = new FileReader(new File(root, file));
scenarios.put(file.replace(".json", ""),
scenarios.put(file.replace(".json", ""),
new JSONObject(IOUtils.toString(reader)));
} finally {
IOUtils.closeQuietly(reader);
Expand All @@ -93,14 +95,14 @@ public boolean isTestsExist(final String assignment) {
if(assignment == null) {
return false;
}
return getTestsAssigmentLocation(assignment).exists();
return getTestsAssignmentLocation(assignment).exists();
}

public TestRunner createTestRunner(final String email, final String assigment,
public TestRunner createTestRunner(final String email, final String assignment,
final String packageName, final byte[] archive)
throws JSONException, IOException {
final File root = getTestsAssigmentLocation(assigment);
return new TestRunnerImpl(email, assigment, packageName, archive, readModels(root),
final File root = getTestsAssignmentLocation(assignment);
return new TestRunnerImpl(email, assignment, packageName, archive, readModels(root),
readScenarios(root));
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/META-INF/persistence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<persistence-unit name="ru.ifmo.ailab.drools.tester">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/dt-db"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://mysql/dt-db"/>
<property name="javax.persistence.jdbc.user" value="dt-user"/>
<property name="javax.persistence.jdbc.password" value="dt-password"/>

<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.driver_class" value="com.mysql.cj.jdbc.Driver"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.connection.characterEncoding" value="utf8"/>
</properties>
</persistence-unit>
</persistence>
</persistence>
7 changes: 6 additions & 1 deletion src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
</head>
<body>
<div class="container">
<a href="https://github.com/ailabitmo/drools-tester">
<img style="position: absolute; top: 0; left: 0; border: 0;"
src="https://camo.githubusercontent.com/567c3a48d796e2fc06ea80409cc9dd82bf714434/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f6c6566745f6461726b626c75655f3132313632312e706e67"
alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_left_darkblue_121621.png">
</a>
<div class="ai-header">
<h1 class="text-center">Система проверки решений</h1>
</div>
Expand All @@ -28,7 +33,7 @@
<div ng-view></div>

<footer class="ai-footer">
Разработано в <a href="http://ailab.ifmo.ru">ISST Laboratory</a> @ <a href="http://ifmo.ru">ITMO University</a>
Разработано на кафедре <a href="http://iam.ifmo.ru">Информатики и прикладной математики</a> @ <a href="http://ifmo.ru">Университет ИТМО</a>
</footer>
</div>
</body>
Expand Down

0 comments on commit 217cdd6

Please sign in to comment.