From d26fb582c1db93eab8faaf809876d8a084027320 Mon Sep 17 00:00:00 2001 From: Dan Alima Date: Sat, 30 Dec 2023 22:53:27 +0200 Subject: [PATCH] disable snapshot for registries, create a Dockerfile, and more... --- .github/workflows/maven-build.yml | 24 ++++++++++++++---------- Dockerfile | 14 ++++++++++++++ pom.xml | 4 ++-- 3 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index 699769735..99eef026f 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -23,28 +23,32 @@ jobs: uses: actions/setup-java@v2 with: java-version: ${{matrix.java}} - distribution: 'adopt' + distribution: 'amazoncorretto' cache: maven + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Compile the code - run: ./mvnw -B package + run: ./mvnw -B package -D skipTests - name: Run the tests run: ./mvnw test - name: Package the project as a runnable Docker image - run: ./mvnw spring-boot:build-image + run: docker buildx build --platform linux/arm64,linux/amd64 --load -t my_repo/jfrog_assignment:${{ github.sha }} . - name: Scan the project with your preferred SCA tool uses: aquasecurity/trivy-action@master with: - image-ref: 'docker.io/library/spring-petclinic:3.2.0-JFrog_Assignment' + image-ref: 'my_repo/jfrog_assignment:${{ github.sha }}' format: 'sarif' output: 'trivy-results.sarif' ignore-unfixed: true vuln-type: 'os,library' severity: 'CRITICAL,HIGH' - - name: Upload Trivy scan results to GitHub Security tab - uses: github/codeql-action/upload-sarif@v2 + - uses: actions/upload-artifact@v4 with: - sarif_file: 'trivy-results.sarif' - - - name: Tag Docker image - run: docker tag docker.io/library/spring-petclinic:3.2.0-JFrog_Assignment my_repo/spring-petclinic:3.2.0-JFrog_Assignment + name: trivy-results.sarif + path: trivy-results.sarif + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..cf7515c8e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# Use a base image with Java runtime +FROM amazoncorretto:17-alpine + +# Set the working directory inside the container +WORKDIR /app + +# Copy the compiled JAR file into the container at /app +COPY target/spring-petclinic-*.jar /app/app.jar + +# Expose the port that your application will run on +EXPOSE 8080 + +# Specify the command to run your application +CMD ["java", "-jar", "app.jar"] diff --git a/pom.xml b/pom.xml index 439a33953..f6fef57e0 100644 --- a/pom.xml +++ b/pom.xml @@ -281,7 +281,7 @@ Maven Repository Switchboard https://repo1.maven.org/maven2 - true + false @@ -292,7 +292,7 @@ Maven Plugin Repository https://repo1.maven.org/maven2 - true + false