Skip to content

Commit 8a09481

Browse files
author
Robin Duda
committed
Add Dockerfile.
1 parent 32e6d7b commit 8a09481

File tree

8 files changed

+85
-48
lines changed

8 files changed

+85
-48
lines changed

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM anapsix/alpine-java:latest
2+
3+
MAINTAINER codingchili@github
4+
5+
# run mvn clean package to build the jar file.
6+
# to build the docker image run: docker build .
7+
8+
9+
RUN mkdir -p /opt/excelastic
10+
COPY docker/configuration.json /opt/excelastic
11+
COPY docker/bootstrap.sh /opt/excelastic
12+
COPY excelastic-*.jar /opt/excelastic/excelastic.jar
13+
RUN chmod +x /opt/excelastic/bootstrap.sh && \
14+
apk add gettext
15+
16+
WORKDIR /opt/excelastic
17+
18+
ENV es_host localhost
19+
ENV es_port 9200
20+
21+
EXPOSE 5252:5252/tcp
22+
23+
ENTRYPOINT ["/bin/sh", "-c", "/opt/excelastic/bootstrap.sh"]

docker/bootstrap.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
envsubst < configuration.json > configuration.json && java -jar excelastic.jar

docker/configuration.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"web_port": 5252,
3+
"elastic_port": $es_port,
4+
"elastic_host": "$es_host",
5+
"elastic_tls": false,
6+
"authentication": false,
7+
"basic": "username:password"
8+
}

src/main/java/com/codingchili/Model/CSVParser.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import java.nio.channels.FileChannel;
1212
import java.util.*;
1313
import java.util.concurrent.atomic.AtomicInteger;
14-
import java.util.logging.Level;
1514

1615
/**
1716
* @author Robin Duda

src/main/java/com/codingchili/Model/ExcelParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public void parseRowRange(int begin, int count, Consumer<JsonObject> consumer) {
138138
public void free() {
139139
try {
140140
workbook.close();
141+
file.delete();
141142
} catch (IOException e) {
142143
logger.onError(e);
143144
}
Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
package com.codingchili.Model;
2-
3-
import io.vertx.core.json.JsonObject;
4-
import org.reactivestreams.Publisher;
5-
6-
import java.io.FileNotFoundException;
7-
import java.util.Set;
8-
9-
/**
10-
* @author Robin Duda
11-
* <p>
12-
* Interface used to support different input file formats.
13-
* The parser is subscribable and emits json objects for importing.
14-
*/
15-
public interface FileParser extends Publisher<JsonObject> {
16-
17-
/**
18-
* @param localFileName a file on disk to be parsed, do not read this into memory
19-
* as it could be potentially very large.
20-
* @param offset indicates how many empty rows to skip before finding the titles.
21-
* @param fileName the original name of the file to be imported.
22-
*/
23-
void setFileData(String localFileName, int offset, String fileName) throws FileNotFoundException;
24-
25-
/**
26-
* @return a set of file extensions that this fileparser supports.
27-
*/
28-
Set<String> getSupportedFileExtensions();
29-
30-
/**
31-
* Parses the excel file to make sure that it is parseable without allocating memory
32-
* for the result. This should be called before importing to make
33-
* sure any imports does not fail halfway through.
34-
*/
35-
void initialize();
36-
37-
/**
38-
* @return the number of elements that was parsed.
39-
*/
40-
int getNumberOfElements();
41-
42-
43-
/**
44-
* Releases any resources associated with the FileParser.
45-
*/
46-
void free();
47-
}
1+
package com.codingchili.Model;
2+
3+
import io.vertx.core.json.JsonObject;
4+
import org.reactivestreams.Publisher;
5+
6+
import java.io.FileNotFoundException;
7+
import java.util.Set;
8+
9+
/**
10+
* @author Robin Duda
11+
* <p>
12+
* Interface used to support different input file formats.
13+
* The parser is subscribable and emits json objects for importing.
14+
*/
15+
public interface FileParser extends Publisher<JsonObject> {
16+
17+
/**
18+
* @param localFileName a file on disk to be parsed, do not read this into memory
19+
* as it could be potentially very large.
20+
* @param offset indicates how many empty rows to skip before finding the titles.
21+
* @param fileName the original name of the file to be imported.
22+
*/
23+
void setFileData(String localFileName, int offset, String fileName) throws FileNotFoundException;
24+
25+
/**
26+
* @return a set of file extensions that this fileparser supports.
27+
*/
28+
Set<String> getSupportedFileExtensions();
29+
30+
/**
31+
* Parses the excel file to make sure that it is parseable without allocating memory
32+
* for the result. This should be called before importing to make
33+
* sure any imports does not fail halfway through.
34+
*/
35+
void initialize();
36+
37+
/**
38+
* @return the number of elements that was parsed.
39+
*/
40+
int getNumberOfElements();
41+
42+
43+
/**
44+
* Releases any resources associated with the FileParser.
45+
*/
46+
void free();
47+
}

src/main/java/com/codingchili/logging/ApplicationLogger.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,8 @@ public static String traceToText(Throwable throwable) {
211211
throwable.printStackTrace(new PrintWriter(writer));
212212
return writer.toString();
213213
}
214+
215+
public void websiteStarted(int webPort) {
216+
logger.info("Started website on port " + webPort);
217+
}
214218
}

src/test/java/com/codingchili/TestParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public void onComplete() {
101101
context.assertEquals("cell " + (ROW_OFFSET + 1 + i) + "." + 2, json.getString("Column 2"));
102102
context.assertEquals("cell " + (ROW_OFFSET + 1 + i) + "." + 3, json.getString("Column 3"));
103103
}
104+
parser.free();
104105
}
105106
});
106107
}

0 commit comments

Comments
 (0)