diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..79fc74a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +FROM azul/zulu-openjdk-alpine:11.0.20.1-11.66.19-arm64 AS base +RUN apk update && apk add maven +COPY < + + ./.m2 + +EOF + +FROM base AS deps +WORKDIR /deps +COPY pom.xml /deps/ +COPY backend/pom.xml /deps/backend/pom.xml +COPY webp-io/pom.xml /deps/webp-io/pom.xml + +RUN mvn dependency:go-offline -s /settings/settings.xml + +FROM base AS build +WORKDIR /sources +COPY . /sources/ +COPY --from=deps /deps/.m2 /sources/.m2 + +RUN mvn clean package -Dmaven.test.skip=true -s /settings/settings.xml + +FROM azul/zulu-openjdk-alpine:11.0.20.1-11.66.19-arm64 + +RUN apk update \ + && apk add ffmpeg python3 py3-pip libwebp-tools optipng \ + && pip3 install 'lottie==0.6.4' --break-system-packages + +# Create the application directory +RUN mkdir /app + +COPY --from=build /sources/backend/target/service.jar /app + +WORKDIR /app + +CMD [ "java", "-jar", "/app/service.jar" ] \ No newline at end of file diff --git a/backend/pom.xml b/backend/pom.xml index 51f3227..43d07f8 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -166,11 +166,16 @@ - ${project.artifactId} + service ${project.basedir}/src/main/kotlin ${project.basedir}/src/test/kotlin + + org.apache.maven.plugins + maven-dependency-plugin + 3.1.1 + org.jetbrains.kotlin kotlin-maven-plugin diff --git a/backend/src/main/kotlin/com/vdsirotkin/telegram/mystickersbot/MyStickersBotApplication.kt b/backend/src/main/kotlin/com/vdsirotkin/telegram/mystickersbot/MyStickersBotApplication.kt index a9e7e5c..5fa2782 100644 --- a/backend/src/main/kotlin/com/vdsirotkin/telegram/mystickersbot/MyStickersBotApplication.kt +++ b/backend/src/main/kotlin/com/vdsirotkin/telegram/mystickersbot/MyStickersBotApplication.kt @@ -9,6 +9,31 @@ import org.springframework.scheduling.annotation.EnableScheduling @EnableScheduling class MyStickersBotApplication +private fun ensureExternalTools() { + val runtime = Runtime.getRuntime() + runtime.exec("ffmpeg -version").also { it.waitFor() }.exitValue().let { + if (it != 0) { + throw IllegalStateException("FFmpeg is not installed") + } + } + runtime.exec("optipng -v").also { it.waitFor() }.exitValue().let { + if (it != 0) { + throw IllegalStateException("OptiPNG is not installed") + } + } + runtime.exec("dwebp -h").also { it.waitFor() }.exitValue().let { + if (it != 0) { + throw IllegalStateException("WebP tools are not installed") + } + } + runtime.exec("lottie_convert.py -h").also { it.waitFor() }.exitValue().let { + if (it != 0) { + throw IllegalStateException("Lottie tools are not installed") + } + } +} + fun main(args: Array) { + ensureExternalTools() runApplication(*args) } diff --git a/pom.xml b/pom.xml index 1f4a4fd..575e04b 100644 --- a/pom.xml +++ b/pom.xml @@ -13,4 +13,13 @@ backend + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.1.1 + + + diff --git a/webp-io/src/main/resources/cwebp/linux_x86/cwebp b/webp-io/src/main/resources/cwebp/linux_x86/cwebp deleted file mode 100755 index 5fa25ae..0000000 Binary files a/webp-io/src/main/resources/cwebp/linux_x86/cwebp and /dev/null differ diff --git a/webp-io/src/main/resources/cwebp/linux_x86/dwebp b/webp-io/src/main/resources/cwebp/linux_x86/dwebp deleted file mode 100755 index a88b8ba..0000000 Binary files a/webp-io/src/main/resources/cwebp/linux_x86/dwebp and /dev/null differ diff --git a/webp-io/src/main/resources/cwebp/linux_x86/gif2webp b/webp-io/src/main/resources/cwebp/linux_x86/gif2webp deleted file mode 100755 index cc67f97..0000000 Binary files a/webp-io/src/main/resources/cwebp/linux_x86/gif2webp and /dev/null differ diff --git a/webp-io/src/main/resources/cwebp/linux_x86_64/cwebp b/webp-io/src/main/resources/cwebp/linux_x86_64/cwebp deleted file mode 100755 index eb7e223..0000000 Binary files a/webp-io/src/main/resources/cwebp/linux_x86_64/cwebp and /dev/null differ diff --git a/webp-io/src/main/resources/cwebp/linux_x86_64/dwebp b/webp-io/src/main/resources/cwebp/linux_x86_64/dwebp deleted file mode 100755 index 4ce551a..0000000 Binary files a/webp-io/src/main/resources/cwebp/linux_x86_64/dwebp and /dev/null differ diff --git a/webp-io/src/main/resources/cwebp/linux_x86_64/gif2webp b/webp-io/src/main/resources/cwebp/linux_x86_64/gif2webp deleted file mode 100755 index c5f7486..0000000 Binary files a/webp-io/src/main/resources/cwebp/linux_x86_64/gif2webp and /dev/null differ diff --git a/webp-io/src/main/resources/cwebp/mac_x86_64/cwebp b/webp-io/src/main/resources/cwebp/mac_x86_64/cwebp deleted file mode 100755 index c8e8982..0000000 Binary files a/webp-io/src/main/resources/cwebp/mac_x86_64/cwebp and /dev/null differ diff --git a/webp-io/src/main/resources/cwebp/mac_x86_64/dwebp b/webp-io/src/main/resources/cwebp/mac_x86_64/dwebp deleted file mode 100755 index 764b165..0000000 Binary files a/webp-io/src/main/resources/cwebp/mac_x86_64/dwebp and /dev/null differ diff --git a/webp-io/src/main/resources/cwebp/mac_x86_64/gif2webp b/webp-io/src/main/resources/cwebp/mac_x86_64/gif2webp deleted file mode 100755 index 86b5269..0000000 Binary files a/webp-io/src/main/resources/cwebp/mac_x86_64/gif2webp and /dev/null differ diff --git a/webp-io/src/main/resources/cwebp/windows_x66/cwebp.exe b/webp-io/src/main/resources/cwebp/windows_x66/cwebp.exe deleted file mode 100755 index 81c82c5..0000000 Binary files a/webp-io/src/main/resources/cwebp/windows_x66/cwebp.exe and /dev/null differ diff --git a/webp-io/src/main/resources/cwebp/windows_x66/dwebp.exe b/webp-io/src/main/resources/cwebp/windows_x66/dwebp.exe deleted file mode 100755 index 6e0fa8b..0000000 Binary files a/webp-io/src/main/resources/cwebp/windows_x66/dwebp.exe and /dev/null differ diff --git a/webp-io/src/main/resources/cwebp/windows_x66/freeglut.dll b/webp-io/src/main/resources/cwebp/windows_x66/freeglut.dll deleted file mode 100755 index e30fb4e..0000000 Binary files a/webp-io/src/main/resources/cwebp/windows_x66/freeglut.dll and /dev/null differ diff --git a/webp-io/src/main/resources/cwebp/windows_x66/gif2webp.exe b/webp-io/src/main/resources/cwebp/windows_x66/gif2webp.exe deleted file mode 100755 index 752db7d..0000000 Binary files a/webp-io/src/main/resources/cwebp/windows_x66/gif2webp.exe and /dev/null differ diff --git a/webp-io/src/main/resources/cwebp/windows_x86_64/cwebp.exe b/webp-io/src/main/resources/cwebp/windows_x86_64/cwebp.exe deleted file mode 100755 index fa8c585..0000000 Binary files a/webp-io/src/main/resources/cwebp/windows_x86_64/cwebp.exe and /dev/null differ diff --git a/webp-io/src/main/resources/cwebp/windows_x86_64/dwebp.exe b/webp-io/src/main/resources/cwebp/windows_x86_64/dwebp.exe deleted file mode 100755 index 1e93e24..0000000 Binary files a/webp-io/src/main/resources/cwebp/windows_x86_64/dwebp.exe and /dev/null differ diff --git a/webp-io/src/main/resources/cwebp/windows_x86_64/freeglut.dll b/webp-io/src/main/resources/cwebp/windows_x86_64/freeglut.dll deleted file mode 100755 index 8624d4e..0000000 Binary files a/webp-io/src/main/resources/cwebp/windows_x86_64/freeglut.dll and /dev/null differ diff --git a/webp-io/src/main/resources/cwebp/windows_x86_64/gif2webp.exe b/webp-io/src/main/resources/cwebp/windows_x86_64/gif2webp.exe deleted file mode 100755 index c9f388e..0000000 Binary files a/webp-io/src/main/resources/cwebp/windows_x86_64/gif2webp.exe and /dev/null differ