Compare commits

...

11 Commits

Author SHA1 Message Date
bbb7afce3f Makes the Woodpecker build tag the Docker image with the build number
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-07-15 23:12:03 -05:00
0aaa29b1e2 Tidies up the startup code to make it more readable
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-07-01 21:23:57 -05:00
3e2f0ca681 Adds more logging statements to the album cache service 2024-07-01 21:23:13 -05:00
6646ba4c54 Uses multi-stage Docker build to fix copy issue
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-07-01 17:22:05 -05:00
9779205be0 Docker copy issues continue
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-07-01 17:04:54 -05:00
c178cf1bf9 Continuing to troubleshoot Docker build issues
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-07-01 16:51:58 -05:00
1b9397234a Still troubleshooting Docker build issues
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-07-01 16:48:45 -05:00
b5206af920 Fixes Dockerfile copy line
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-07-01 16:25:33 -05:00
7b25ceb1af Adds debug stuff for Dockerfile
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-07-01 16:20:01 -05:00
1650afa030 Adds Woodpecker pipeline config
Some checks failed
ci/woodpecker/manual/woodpecker Pipeline failed
2024-07-01 16:09:36 -05:00
57788fe43e Adds Dockerfile 2024-07-01 16:07:50 -05:00
4 changed files with 57 additions and 13 deletions

15
.woodpecker.yaml Normal file
View File

@@ -0,0 +1,15 @@
when:
branch: main
event:
- push
- manual
steps:
- name: build
image: woodpeckerci/plugin-docker-buildx
settings:
repo: git.halfbinary.net/${CI_REPO_OWNER}/prettyplayerapi
registry: git.halfbinary.net
tags: ${CI_PIPELINE_NUMBER}
username: ${CI_REPO_OWNER}
password:
from_secret: docker_password

27
Dockerfile Normal file
View File

@@ -0,0 +1,27 @@
FROM amazoncorretto:21-alpine-jdk as build
LABEL maintainer="Alex Arbit <aarbit@gmail.com>"
WORKDIR /app
COPY build.gradle.kts .
COPY gradlew .
COPY gradlew.bat .
COPY settings.gradle.kts .
COPY gradle ./gradle
COPY src ./src
RUN apk --no-cache add gradle
RUN gradle bootJar
RUN ls -al
RUN ls -al /
FROM amazoncorretto:21-alpine-jdk
COPY --from=build /app/build/libs/*.jar app.jar
RUN ls -al
EXPOSE 8080
ENTRYPOINT ["java","-jar","app.jar"]

View File

@@ -32,6 +32,7 @@ class AlbumCacheService(
it.isFile && it.extension == "mp3" && it.name.startsWith("01.")
}
.toList()
logger.info { "Album count: ${fileList.count()}" }
when (type) {
CacheType.ART -> cacheArt(fileList)
CacheType.NEW -> cacheNew(fileList)
@@ -40,6 +41,7 @@ class AlbumCacheService(
}
suspend fun cacheAll(fileList: List<File>) {
logger.debug { "Caching all albums..." }
fileList.forEach {
val mp3File = Mp3File(it)
val folderPath = it.parentFile.toPath()
@@ -57,9 +59,11 @@ class AlbumCacheService(
)
)
}
logger.debug { "...completed caching all albums." }
}
suspend fun cacheNew(fileList: List<File>) {
logger.debug { "Caching new albums..." }
fileList.forEach {
val folderPath = it.parentFile.toPath()
val folderHash = folderPath.name.hashCode().toString()
@@ -79,9 +83,11 @@ class AlbumCacheService(
)
}
}
logger.debug { "...completed caching new albums." }
}
suspend fun cacheArt(fileList: List<File>) {
logger.debug { "Caching album art..." }
fileList.forEach {
val folderPath = it.parentFile.toPath()
val folderHash = folderPath.name.hashCode().toString()
@@ -89,6 +95,7 @@ class AlbumCacheService(
launch { getAndWriteAlbumImageFile(it, folderHash, folderPath) }
}
}
logger.debug { "...completed caching album art." }
}
fun createAlbumArtRootDir() {

View File

@@ -21,19 +21,14 @@ class StartupService(
@Async
@EventListener(ApplicationStartedEvent::class)
suspend fun onStartup() {
if (withContext(ioDispatcher) {
albumRepository.count()
} == 0L) {
val cacheType = if (withContext(ioDispatcher) { albumRepository.count() } == 0L) {
CacheType.ALL}
else {
CacheType.NEW
}
coroutineScope {
launch {
albumCacheService.cacheAlbums(CacheType.ALL)
}
}
} else {
coroutineScope {
launch {
albumCacheService.cacheAlbums(CacheType.NEW)
}
albumCacheService.cacheAlbums(cacheType)
}
}
}