Updated Dockerfile
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
Sambo Chea 2023-03-09 18:32:09 +07:00
parent a519d68249
commit 84fbf6debc
Signed by: sombochea
GPG Key ID: 3C7CF22A05D95490
6 changed files with 34 additions and 57 deletions

7
.dockerignore Normal file
View File

@ -0,0 +1,7 @@
.idea/
.gradle/
k8s/
build/
.github/
uploads/
apps/

View File

@ -1,24 +1,28 @@
# Builder # Builder
FROM cubetiq/openjdk:11u-ubuntu as builder FROM bellsoft/liberica-openjdk-alpine-musl as builder
LABEL maintainer="sombochea@cubetiqs.com" LABEL maintainer="sombochea@cubetiqs.com"
WORKDIR /app 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 # Build for container image
FROM cubetiq/openjdk:jre-11u-debian FROM bellsoft/liberica-openjre-alpine-musl
LABEL maintainer="sombochea@cubetiqs.com" 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 # App root path
WORKDIR /opt/cubetiq WORKDIR /opt/cubetiq
@ -29,7 +33,7 @@ VOLUME ["/opt/cubetiq", "/data"]
ARG API_BUILD_DIR=api/build ARG API_BUILD_DIR=api/build
# Copy the app bundle to the workdir # 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 # App profile will run with
ENV PROFILE=dev ENV PROFILE=dev

View File

@ -8,8 +8,8 @@ plugins {
kotlin("plugin.jpa") kotlin("plugin.jpa")
} }
val kotlinVersion = "1.7.22" val kotlinVersion = "1.8.10"
val springBootVersion = "3.0.0" val springBootVersion = "3.0.4"
// find the last commit // find the last commit
fun getGitHashLastCommit(): String { fun getGitHashLastCommit(): String {
@ -60,3 +60,7 @@ dependencies {
tasks.withType<Test> { tasks.withType<Test> {
useJUnitPlatform() useJUnitPlatform()
} }
tasks.withType<org.springframework.boot.gradle.tasks.bundling.BootJar> {
archiveFileName.set("api.jar")
}

View File

@ -1,5 +1,5 @@
http: http:
port: ${HTTP_PORT:8080} port: ${PORT:8080}
server: server:
port: ${SERVER_PORT:8443} port: ${SERVER_PORT:8443}
ssl: ssl:
@ -15,10 +15,6 @@ spring:
active: ${APP_PROFILE:demo} active: ${APP_PROFILE:demo}
application: application:
name: ${SERVICE_NAME:cubetiq-api-service} name: ${SERVICE_NAME:cubetiq-api-service}
redis:
enabled: ${REDIS_ENABLED:false}
host: ${REDIS_HOST:localhost}
password: ${REDIS_PASSWORD:null}
datasource: datasource:
enabled: ${DATASOURCE_ENABLED:true} enabled: ${DATASOURCE_ENABLED:true}
driverClassName: ${DATASOURCE_DRIVER_CLASS_NAME:org.h2.Driver} driverClassName: ${DATASOURCE_DRIVER_CLASS_NAME:org.h2.Driver}
@ -32,8 +28,12 @@ spring:
database-platform: ${JPA_DATABASE_PLATFORM:org.hibernate.dialect.H2Dialect} database-platform: ${JPA_DATABASE_PLATFORM:org.hibernate.dialect.H2Dialect}
data: data:
redis: redis:
enabled: ${REDIS_ENABLED:false}
host: ${REDIS_HOST:localhost}
password: ${REDIS_PASSWORD:null}
repositories: repositories:
enabled: ${DATA_REDIS_REPOSITORIES_ENABLED:false} enabled: ${DATA_REDIS_REPOSITORIES_ENABLED:false}
modules: modules:
user: user:
enabled: ${MODULE_USER_ENABLED:true} enabled: ${MODULE_USER_ENABLED:true}

View File

@ -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"]

1
system.properties Normal file
View File

@ -0,0 +1 @@
java.runtime.version=zulu-17