diff --git a/Dockerfile b/Dockerfile index cb7b151..e65449c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,31 @@ -# Build Rainbow jar -FROM gradle:8.5-alpine AS build +# +# Build Rainbow API jar +# +FROM gradle:8.12.0-jdk21-alpine AS build -COPY --chown=gradle:gradle . /home/gradle/src -WORKDIR /home/gradle/src +WORKDIR /home/gradle +COPY --chown=gradle:gradle build.gradle src/ /home/gradle/src/ +COPY --chown=gradle:gradle build.gradle settings.gradle /home/gradle/ RUN gradle build --no-daemon # no daemon since building only once +# # Launch Rainbow API -FROM openjdk:17-jdk-slim AS start +# +FROM eclipse-temurin:21-alpine AS runtime -RUN mkdir /src -COPY --from=build /home/gradle/src/build/libs/rainbow-1.0.0.jar /src/rainbow-1.0.0.jar +ARG API_NAME=rainbow-api +ARG API_VERSION=1.1.0 -ENTRYPOINT ["java","-jar","/src/rainbow-1.0.0.jar"] \ No newline at end of file +LABEL name=$API_NAME \ + version=$API_VERSION \ + author="Derek Garcia" \ + description="API service to navigate and search courses available at the University of Hawaii" + +RUN adduser -D rainbow + +WORKDIR /rainbow +COPY --from=build --chown=rainbow:rainbow /home/gradle/build/libs/$API_NAME-$API_VERSION.jar /rainbow/rainbow.jar + +USER rainbow +ENTRYPOINT ["java","-jar","rainbow.jar"] \ No newline at end of file diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100644 index 0000000..d512306 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Parse version from properties +VERSION="1.1.0" + +# Build jar +echo "Building jar. . ." +./gradlew -q clean bootJar + +# Launch jar +echo "Done! Launching api. . ." +java -jar ./build/libs/rainbow-${VERSION}.jar \ No newline at end of file diff --git a/compose.yaml b/compose.yaml deleted file mode 100644 index 5192e2e..0000000 --- a/compose.yaml +++ /dev/null @@ -1,8 +0,0 @@ -services: - # Rainbow API service - api: - container_name: rainbow-api - image: rainbow-api:1.0.0 - build: . - ports: - - "8080:8080" \ No newline at end of file diff --git a/readme.md b/readme.md index 9f5f854..a2c3cdb 100644 --- a/readme.md +++ b/readme.md @@ -31,7 +31,7 @@ gradle bootJar # via Gradle ./gradlew bootJar # or via Gradle Wrapper # Run Jar -java -jar ./build/libs/rainbow-1.0.0.jar +java -jar ./build/libs/rainbow-1.1.0.jar ``` ### Docker