-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Move dockerfile so we can have multiple
- Loading branch information
Showing
5 changed files
with
48 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
FROM eclipse-temurin:21-jre-jammy | ||
|
||
ADD backend/build/libs/backend.jar /app/backend.jar | ||
ADD build/libs/backend.jar /app/backend.jar | ||
|
||
WORKDIR /app | ||
CMD ["java", "-jar", "/app/backend.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package dev.triumphteam.backend.website | ||
|
||
import com.github.benmanes.caffeine.cache.Cache | ||
import com.github.benmanes.caffeine.cache.Caffeine | ||
import io.ktor.http.ContentType | ||
import io.ktor.http.HttpStatusCode | ||
import io.ktor.http.content.TextContent | ||
import io.ktor.http.withCharset | ||
import io.ktor.server.application.ApplicationCall | ||
import io.ktor.server.response.respond | ||
import kotlinx.html.HTML | ||
import kotlinx.html.html | ||
import kotlinx.html.stream.appendHTML | ||
import kotlin.time.Duration.Companion.minutes | ||
import kotlin.time.toJavaDuration | ||
|
||
private val pageCache: Cache<String, TextContent> = Caffeine.newBuilder() | ||
.expireAfterWrite(10.minutes.toJavaDuration()) | ||
.build() | ||
|
||
public suspend fun ApplicationCall.respondHtmlCached(id: String, block: HTML.() -> Unit) { | ||
|
||
val cached = pageCache.getIfPresent(id) | ||
if (cached != null) { | ||
respond(cached) | ||
return | ||
} | ||
|
||
val text = buildString { | ||
append("<!DOCTYPE html>\n") | ||
appendHTML().html(block = block) | ||
} | ||
|
||
respond( | ||
message = TextContent(text, ContentType.Text.Html.withCharset(Charsets.UTF_8), HttpStatusCode.OK).also { | ||
pageCache.put(id, it) | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters