Skip to content

Commit

Permalink
add commons and bump jvm
Browse files Browse the repository at this point in the history
  • Loading branch information
centralhardware committed Oct 8, 2024
1 parent 491dbcb commit c29e686
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
FROM gradle:jdk21-graal as gradle
FROM gradle:jdk22-graal as gradle

COPY ./ ./

RUN gradle fatJar

FROM findepi/graalvm:java21
FROM findepi/graalvm:java22

WORKDIR /znatokiBot

COPY --from=gradle /home/gradle/build/libs/letMeGoogleThatForYou-1.0-SNAPSHOT-standalone.jar .

RUN apt-get update && apt-get install -y curl && apt-get clean && rm -rf /var/lib/apt/lists/*
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD curl --fail http://localhost:80/health || exit 1
CMD curl --fail http://localhost:81/health || exit 1

CMD ["java", "-jar", "letMeGoogleThatForYou-1.0-SNAPSHOT-standalone.jar" ]
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ version = "1.0-SNAPSHOT"

repositories {
mavenCentral()
maven("https://jitpack.io")
}

dependencies {
implementation("dev.inmo:tgbotapi:18.2.1")
implementation("com.github.centralhardware:telegram-bot-commons:efefa401e3")
implementation("com.github.seratch:kotliquery:1.9.0")
}

tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(21)
}

tasks {
val fatJar = register<Jar>("fatJar") {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
13 changes: 6 additions & 7 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import com.sun.net.httpserver.HttpServer
import dev.inmo.kslog.common.KSLog
import dev.inmo.kslog.common.LogLevel
import dev.inmo.kslog.common.configure
import dev.inmo.kslog.common.info
import dev.inmo.kslog.common.setDefaultKSLog
import dev.inmo.kslog.common.warning
import dev.inmo.tgbotapi.bot.ktor.HealthCheckKtorPipelineStepsHolder
import dev.inmo.tgbotapi.extensions.api.answers.answer
import dev.inmo.tgbotapi.extensions.api.answers.answerInlineQuery
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
Expand All @@ -15,7 +14,6 @@ import dev.inmo.tgbotapi.types.LinkPreviewOptions
import dev.inmo.tgbotapi.types.message.HTML
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import java.net.InetSocketAddress
import java.net.URLEncoder
import java.nio.charset.StandardCharsets
import java.util.concurrent.atomic.AtomicInteger
Expand Down Expand Up @@ -59,12 +57,13 @@ private fun getArticle(
hideUrl = true
)

val healthChecker = HealthCheckKtorPipelineStepsHolder()
suspend fun main() {
HttpServer.create().apply { bind(InetSocketAddress(80), 0); createContext("/health") { it.sendResponseHeaders(200, 0); it.responseBody.close() }; start() }
setDefaultKSLog(KSLog("letMeGoogleThatForYou", minLoggingLevel = LogLevel.INFO))
KSLog.configure("LetMeGoogleThatForYou")
telegramBotWithBehaviourAndLongPolling(System.getenv("BOT_TOKEN"),
CoroutineScope(Dispatchers.IO),
defaultExceptionsHandler = { KSLog.warning("", it) }) {
defaultExceptionsHandler = { KSLog.warning("", it) },
builder = { pipelineStepsHolder = healthChecker }) {
onAnyInlineQuery {
KSLog.info(it.query)
if (it.query.isBlank()) {
Expand Down

0 comments on commit c29e686

Please sign in to comment.