diff --git a/Dockerfile b/Dockerfile index 22d51b4..d98dbe1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,18 @@ -# Adapted from: https://github.com/PaperMC/bibliothek/blob/063cc014193b6ea160b3cabc7b93f70009e1fb2a/Dockerfile -ARG JAVA_VERSION=17 -ARG JVM_FLAVOR=hotspot - -FROM eclipse-temurin:${JAVA_VERSION}-jdk-alpine AS builder -WORKDIR /build - -COPY ./ ./ -RUN ./gradlew clean buildForDocker --no-daemon - - -ARG JAVA_VERSION -ARG JVM_FLAVOR - -FROM eclipse-temurin:${JAVA_VERSION}-alpine -WORKDIR /app +FROM eclipse-temurin:17-alpine # Install curl for the healthcheck RUN apk update && apk add curl RUN addgroup -S pingapi \ && adduser -S pingapi -G pingapi \ - && chown -R pingapi:pingapi /app + && chown -R pingapi:pingapi /opt/app USER pingapi:pingapi +WORKDIR /opt/app + +COPY build/libs/ServerPingApi.jar ServerPingApi.jar +COPY ./docker/default.application.yaml ./default.application.yaml + EXPOSE 8080 # We override default config location search path, @@ -31,7 +21,6 @@ EXPOSE 8080 # but they take precedence over config file # https://docs.spring.io/spring-boot/docs/1.5.6.RELEASE/reference/html/boot-features-external-config.html ENV SPRING_CONFIG_LOCATION="optional:classpath:/,optional:classpath:/config/,file:./default.application.yaml,optional:file:./,optional:file:./config/" -COPY ./docker/default.application.yaml ./default.application.yaml HEALTHCHECK --interval=30s --timeout=30s --start-period=5s \ --retries=3 CMD [ "sh", "-c", "echo -n 'curl localhost:8080... '; \ @@ -41,5 +30,5 @@ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s \ echo Fail && exit 2\ )"] -COPY --from=builder /build/build/libs/docker/serverpingapi.jar ./ -CMD ["java", "-jar", "/app/serverpingapi.jar"] + +CMD ["java", "-jar", "ServerPingApi.jar"]