add dockerfile environment

This commit is contained in:
InsanusMokrassar 2021-11-21 20:51:56 +06:00
parent e86d07d25d
commit fcc0b49576
7 changed files with 51 additions and 1 deletions

9
Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM adoptopenjdk/openjdk11
USER 1000
VOLUME /config.json
ENTRYPOINT ["/telegram_bot/bin/telegram_bot", "TOKEN"]
ADD ./build/distributions/telegram_bot.tar /

19
Makefile Normal file
View File

@ -0,0 +1,19 @@
#!make
.ONESHELL:
.PHONY:
clean:
./gradlew clean
build:
./gradlew build
start:
./gradlew run
startCompose:
docker-compose build && docker-compose up
buildAndStartCompose:
make clean build startCompose

View File

@ -17,6 +17,13 @@ output you will get your bot information like:
ExtendedBot(id=ChatId(chatId=1234567890), username=Username(username=@username_of_your_bot), firstName=Name of bot, lastName=, canJoinGroups=(some boolean), canReadAllGroupMessages=(some boolean), supportsInlineQueries=(some boolean)) ExtendedBot(id=ChatId(chatId=1234567890), username=Username(username=@username_of_your_bot), firstName=Name of bot, lastName=, canJoinGroups=(some boolean), canReadAllGroupMessages=(some boolean), supportsInlineQueries=(some boolean))
``` ```
### Docker
In this template there is template-like [docker-compose](docker-compose.yml) and [docker](Dockerfile) files. Besides,
there is [Makefile](Makefile) and you may use something like `make buildAndStartCompose` to start your bot.
It is important to replace `"TOKEN"` in [Dockerfile](Dockerfile) or remove and add some config as a volume.
## What next? ## What next?
There are several ways to continue: There are several ways to continue:

View File

@ -28,3 +28,8 @@ dependencies {
application { application {
mainClassName = 'telegram_bot.AppKt' mainClassName = 'telegram_bot.AppKt'
} }
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

6
docker-compose.yml Normal file
View File

@ -0,0 +1,6 @@
version: "3.4"
services:
server:
build: .
restart: unless-stopped

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -27,5 +27,9 @@ suspend fun main(args: Array<String>) {
// simply reply :) // simply reply :)
reply(it, "Hello, I am ${me.firstName}") reply(it, "Hello, I am ${me.firstName}")
} }
// That will be called on the end of bot initiation. After that prinln will be started long polling and bot will
// react on your commands
println(me)
}.join() }.join()
} }