Skip to content

Commit

Permalink
Add Dockerfile.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Duda committed Oct 28, 2018
1 parent 32e6d7b commit 8a09481
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 48 deletions.
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM anapsix/alpine-java:latest

MAINTAINER codingchili@github

# run mvn clean package to build the jar file.
# to build the docker image run: docker build .


RUN mkdir -p /opt/excelastic
COPY docker/configuration.json /opt/excelastic
COPY docker/bootstrap.sh /opt/excelastic
COPY excelastic-*.jar /opt/excelastic/excelastic.jar
RUN chmod +x /opt/excelastic/bootstrap.sh && \
apk add gettext

WORKDIR /opt/excelastic

ENV es_host localhost
ENV es_port 9200

EXPOSE 5252:5252/tcp

ENTRYPOINT ["/bin/sh", "-c", "/opt/excelastic/bootstrap.sh"]
1 change: 1 addition & 0 deletions docker/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
envsubst < configuration.json > configuration.json && java -jar excelastic.jar
8 changes: 8 additions & 0 deletions docker/configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"web_port": 5252,
"elastic_port": $es_port,
"elastic_host": "$es_host",
"elastic_tls": false,
"authentication": false,
"basic": "username:password"
}
1 change: 0 additions & 1 deletion src/main/java/com/codingchili/Model/CSVParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.nio.channels.FileChannel;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;

/**
* @author Robin Duda
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/codingchili/Model/ExcelParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public void parseRowRange(int begin, int count, Consumer<JsonObject> consumer) {
public void free() {
try {
workbook.close();
file.delete();
} catch (IOException e) {
logger.onError(e);
}
Expand Down
94 changes: 47 additions & 47 deletions src/main/java/com/codingchili/Model/FileParser.java
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
package com.codingchili.Model;

import io.vertx.core.json.JsonObject;
import org.reactivestreams.Publisher;

import java.io.FileNotFoundException;
import java.util.Set;

/**
* @author Robin Duda
* <p>
* Interface used to support different input file formats.
* The parser is subscribable and emits json objects for importing.
*/
public interface FileParser extends Publisher<JsonObject> {

/**
* @param localFileName a file on disk to be parsed, do not read this into memory
* as it could be potentially very large.
* @param offset indicates how many empty rows to skip before finding the titles.
* @param fileName the original name of the file to be imported.
*/
void setFileData(String localFileName, int offset, String fileName) throws FileNotFoundException;

/**
* @return a set of file extensions that this fileparser supports.
*/
Set<String> getSupportedFileExtensions();

/**
* Parses the excel file to make sure that it is parseable without allocating memory
* for the result. This should be called before importing to make
* sure any imports does not fail halfway through.
*/
void initialize();

/**
* @return the number of elements that was parsed.
*/
int getNumberOfElements();


/**
* Releases any resources associated with the FileParser.
*/
void free();
}
package com.codingchili.Model;

import io.vertx.core.json.JsonObject;
import org.reactivestreams.Publisher;

import java.io.FileNotFoundException;
import java.util.Set;

/**
* @author Robin Duda
* <p>
* Interface used to support different input file formats.
* The parser is subscribable and emits json objects for importing.
*/
public interface FileParser extends Publisher<JsonObject> {

/**
* @param localFileName a file on disk to be parsed, do not read this into memory
* as it could be potentially very large.
* @param offset indicates how many empty rows to skip before finding the titles.
* @param fileName the original name of the file to be imported.
*/
void setFileData(String localFileName, int offset, String fileName) throws FileNotFoundException;

/**
* @return a set of file extensions that this fileparser supports.
*/
Set<String> getSupportedFileExtensions();

/**
* Parses the excel file to make sure that it is parseable without allocating memory
* for the result. This should be called before importing to make
* sure any imports does not fail halfway through.
*/
void initialize();

/**
* @return the number of elements that was parsed.
*/
int getNumberOfElements();


/**
* Releases any resources associated with the FileParser.
*/
void free();
}
4 changes: 4 additions & 0 deletions src/main/java/com/codingchili/logging/ApplicationLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,8 @@ public static String traceToText(Throwable throwable) {
throwable.printStackTrace(new PrintWriter(writer));
return writer.toString();
}

public void websiteStarted(int webPort) {
logger.info("Started website on port " + webPort);
}
}
1 change: 1 addition & 0 deletions src/test/java/com/codingchili/TestParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public void onComplete() {
context.assertEquals("cell " + (ROW_OFFSET + 1 + i) + "." + 2, json.getString("Column 2"));
context.assertEquals("cell " + (ROW_OFFSET + 1 + i) + "." + 3, json.getString("Column 3"));
}
parser.free();
}
});
}
Expand Down

0 comments on commit 8a09481

Please sign in to comment.