diff --git a/README.md b/README.md index 2a3604e..398bf37 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ # karl-marx +## Deploying + + * Create a fat jar with `sbt assembly` and call it `Bot.jar` + * On the server, create a directory for your bot. Copy `docker-compose.yml` into it, create `data/bot/`, and copy `Bot.jar` into `data/bot/` + * Run `docker-compose up -d` + +You can view logs with `docker-compose logs`, take down the server with `docker-compose down`, and restart it with `docker-compose restart`. \ No newline at end of file diff --git a/build.sbt b/build.sbt index bedec2e..bdb7962 100644 --- a/build.sbt +++ b/build.sbt @@ -3,4 +3,6 @@ name := "karl-marx" version := "0.1" scalaVersion := "2.12.8" -libraryDependencies += "com.bot4s" %% "telegram-core" % "4.2.0-RC1" \ No newline at end of file +libraryDependencies += "com.bot4s" %% "telegram-core" % "4.2.0-RC1" + +mainClass := Some("Runner") diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e3b102d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,19 @@ +version: "2" +services: + bot: + restart: always + image: openjdk:8-jre-stretch + volumes: + - ./data/bot:/bot + working_dir: /bot + entrypoint: java -jar Bot.jar + environment: + - BOT_TOKEN=soandso + depends_on: + - redis + redis: + restart: always + image: redis + entrypoint: redis-server --appendonly yes + volumes: + - ./data/redis:/data \ No newline at end of file diff --git a/project/assembly.sbt b/project/assembly.sbt new file mode 100644 index 0000000..813ce17 --- /dev/null +++ b/project/assembly.sbt @@ -0,0 +1 @@ +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9") \ No newline at end of file diff --git a/src/main/scala/org/congressodeiradicali/karlmarx/Runner.scala b/src/main/scala/org/congressodeiradicali/karlmarx/Runner.scala index b557b01..87f58a2 100644 --- a/src/main/scala/org/congressodeiradicali/karlmarx/Runner.scala +++ b/src/main/scala/org/congressodeiradicali/karlmarx/Runner.scala @@ -7,10 +7,11 @@ object Runner { def main(args: Array[String]): Unit = { val bot = new Bot("657892534:AAEeSKtA9rbo9WCYDenFXygwtNg-YV_EDs4") val eol = bot.run() + /* println("Press [ENTER] to shutdown the bot, it may take a few seconds...") scala.io.StdIn.readLine() - bot.shutdown() // initiate shutdown // Wait for the bot end-of-life + */ Await.result(eol, Duration.Inf) } }