diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7438e43 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.idea/ +.gradle/ +k8s/ +build/ +.github/ +uploads/ +apps/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 1a176ab..41797e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,28 @@ # Builder -FROM cubetiq/openjdk:11u-ubuntu as builder +FROM bellsoft/liberica-openjdk-alpine-musl as builder LABEL maintainer="sombochea@cubetiqs.com" WORKDIR /app -RUN apt-get update && apt-get install -y git +RUN apk update && apk add git -COPY . . +COPY gradlew ./ +COPY gradle ./gradle +RUN ./gradlew -RUN sh gradlew clean bootJar -RUN rm -f build/libs/*-plain.jar + +COPY settings.gradle.kts ./ +COPY build.gradle.kts ./ +COPY api/build.gradle.kts ./api/build.gradle.kts +COPY api/src ./api/src +COPY .git ./.git + +RUN ./gradlew api:bootJar # Build for container image -FROM cubetiq/openjdk:jre-11u-debian +FROM bellsoft/liberica-openjre-alpine-musl LABEL maintainer="sombochea@cubetiqs.com" -# Setup timezone to Phnom Penh -RUN ln -sf /usr/share/zoneinfo/Asia/Phnom_Penh /etc/localtime -RUN echo "Asia/Phnom_Penh" > /etc/timezone - # App root path WORKDIR /opt/cubetiq @@ -29,7 +33,7 @@ VOLUME ["/opt/cubetiq", "/data"] ARG API_BUILD_DIR=api/build # Copy the app bundle to the workdir -COPY --from=builder /app/${API_BUILD_DIR}/libs/api-0.0.1-SNAPSHOT.jar ./api.jar +COPY --from=builder /app/${API_BUILD_DIR}/libs/api.jar ./api.jar # App profile will run with ENV PROFILE=dev diff --git a/api/build.gradle.kts b/api/build.gradle.kts index 622bba3..33c33dd 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -8,8 +8,8 @@ plugins { kotlin("plugin.jpa") } -val kotlinVersion = "1.7.22" -val springBootVersion = "3.0.0" +val kotlinVersion = "1.8.10" +val springBootVersion = "3.0.4" // find the last commit fun getGitHashLastCommit(): String { @@ -60,3 +60,7 @@ dependencies { tasks.withType { useJUnitPlatform() } + +tasks.withType { + archiveFileName.set("api.jar") +} \ No newline at end of file diff --git a/api/src/main/resources/application.yml b/api/src/main/resources/application.yml index d09e7ea..426899e 100644 --- a/api/src/main/resources/application.yml +++ b/api/src/main/resources/application.yml @@ -1,5 +1,5 @@ http: - port: ${HTTP_PORT:8080} + port: ${PORT:8080} server: port: ${SERVER_PORT:8443} ssl: @@ -15,10 +15,6 @@ spring: active: ${APP_PROFILE:demo} application: name: ${SERVICE_NAME:cubetiq-api-service} - redis: - enabled: ${REDIS_ENABLED:false} - host: ${REDIS_HOST:localhost} - password: ${REDIS_PASSWORD:null} datasource: enabled: ${DATASOURCE_ENABLED:true} driverClassName: ${DATASOURCE_DRIVER_CLASS_NAME:org.h2.Driver} @@ -32,8 +28,12 @@ spring: database-platform: ${JPA_DATABASE_PLATFORM:org.hibernate.dialect.H2Dialect} data: redis: + enabled: ${REDIS_ENABLED:false} + host: ${REDIS_HOST:localhost} + password: ${REDIS_PASSWORD:null} repositories: enabled: ${DATA_REDIS_REPOSITORIES_ENABLED:false} + modules: user: enabled: ${MODULE_USER_ENABLED:true} diff --git a/lite.Dockerfile b/lite.Dockerfile deleted file mode 100644 index 9b8ca30..0000000 --- a/lite.Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -# Builder -FROM cubetiq/openjdk:11u-ubuntu as builder -LABEL maintainer="sombochea@cubetiqs.com" - -WORKDIR /app - -RUN apt-get update && apt-get install -y git - -COPY . . - -RUN sh gradlew clean bootJar -RUN rm -f build/libs/*-plain.jar - -# Build for container image -FROM bellsoft/liberica-openjre-alpine-musl -LABEL maintainer="sombochea@cubetiqs.com" - -# Setup timezone to Phnom Penh -RUN ln -sf /usr/share/zoneinfo/Asia/Phnom_Penh /etc/localtime -RUN echo "Asia/Phnom_Penh" > /etc/timezone - -# App root path -WORKDIR /opt/cubetiq - -# App volumn -VOLUME ["/opt/cubetiq", "/data"] - -# Api Module Build Directory -ARG API_BUILD_DIR=api/build - -# Copy the app bundle to the workdir -COPY --from=builder /app/${API_BUILD_DIR}/libs/api-0.0.1-SNAPSHOT.jar ./api.jar - -# App profile will run with -ENV PROFILE=dev -ENV APP_DATA_DIR=/data - -# Entrypoint to app -CMD ["java","-jar", "./api.jar"] \ No newline at end of file diff --git a/system.properties b/system.properties new file mode 100644 index 0000000..705ac56 --- /dev/null +++ b/system.properties @@ -0,0 +1 @@ +java.runtime.version=zulu-17 \ No newline at end of file