Skip to content

Commit

Permalink
Fix dockerfile for new changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rtm516 committed Apr 12, 2024
1 parent 751a733 commit 6a60e34
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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... '; \
Expand All @@ -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"]

0 comments on commit 6a60e34

Please sign in to comment.