diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0d2657a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM bigtruedata/sbt + +ENV DOWNLOAD www.h2database.com/h2-2018-03-18.zip +ENV DATA_DIR /opt/h2-data + +EXPOSE 81 1521 + +# install h2 database +RUN curl ${DOWNLOAD} -o h2.zip \ + && unzip h2.zip -d /opt/ \ + && rm h2.zip \ + && mkdir -p ${DATA_DIR} + +# install mongodb +RUN apt-get update +RUN apt-get install -y mongodb + +# install Xvfb +RUN apt-get -y update && apt-get install -y xvfb +RUN apt-get -y update && apt-get install -y libxrender1 +RUN apt-get -y update && apt-get install -y libxi6 + +RUN service mongodb start + +WORKDIR /sudoku + +ADD . /sudoku diff --git a/src/main/scala/de/htwg/se/sudoku/Sudoku.scala b/src/main/scala/de/htwg/se/sudoku/Sudoku.scala index f873ee4..b2c7754 100755 --- a/src/main/scala/de/htwg/se/sudoku/Sudoku.scala +++ b/src/main/scala/de/htwg/se/sudoku/Sudoku.scala @@ -1,5 +1,7 @@ package de.htwg.se.sudoku +import java.awt.GraphicsEnvironment + import com.google.inject.{Guice, Injector} import de.htwg.se.sudoku.aview.gui.SwingGui import de.htwg.se.sudoku.aview.{HttpServer, Tui} @@ -11,7 +13,11 @@ object Sudoku { val injector: Injector = Guice.createInjector(new SudokuModule) val controller: ControllerInterface = injector.getInstance(classOf[ControllerInterface]) val tui = new Tui(controller) - val gui = new SwingGui(controller) + + if (!GraphicsEnvironment.isHeadless) { + val gui = new SwingGui(controller) + } + val webserver = new HttpServer(controller) controller.createNewGrid @@ -20,8 +26,10 @@ object Sudoku { var input: String = "" do { - input = readLine() - tui.processInputLine(input) + if (Console.in.ready()) { + input = readLine() + tui.processInputLine(input) + } } while (input != "q") webserver.unbind() }