diff --git a/.dockerignore b/.dockerignore index 345b52e..bd0215b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,7 +2,10 @@ .github .gradle .idea -build +build/* +!build/libs +build/libs/* +!build/libs/*.jar out *.iml *.iws diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28fa465..26d8c32 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,5 +44,18 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: "21" + cache: gradle + + - name: Grant Gradle permission + run: chmod +x ./gradlew + + - name: Build application jar + run: ./gradlew --no-daemon clean bootJar -x test + - name: Build Docker image run: docker build -t jobdri-api:${{ github.sha }} . diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 556e069..5e5ef1e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,6 +22,19 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: "21" + cache: gradle + + - name: Grant Gradle permission + run: chmod +x ./gradlew + + - name: Build application jar + run: ./gradlew --no-daemon clean bootJar -x test + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 diff --git a/Dockerfile b/Dockerfile index 03fe4f3..0e31ba8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,10 @@ -FROM eclipse-temurin:21-jdk-alpine AS builder - -WORKDIR /workspace - -COPY gradlew settings.gradle build.gradle ./ -COPY gradle ./gradle -RUN chmod +x gradlew - -COPY src ./src -RUN ./gradlew --no-daemon clean bootJar -x test - FROM eclipse-temurin:21-jre-alpine WORKDIR /app RUN addgroup -S jobdri && adduser -S jobdri -G jobdri -COPY --from=builder /workspace/build/libs/*.jar app.jar +COPY build/libs/*.jar app.jar USER jobdri