Skip to content

Commit

Permalink
build: bump Dockerfile to use java 21 and gradle 8.12
Browse files Browse the repository at this point in the history
  • Loading branch information
dlg1206 committed Dec 26, 2024
1 parent ede0a56 commit 69512d5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 17 deletions.
32 changes: 24 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
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"]
12 changes: 12 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 0 additions & 8 deletions compose.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 69512d5

Please sign in to comment.