From e49b967e6ea9c75167ceb6f054b015b57ec3ffb2 Mon Sep 17 00:00:00 2001 From: Alessio Cialini Date: Wed, 26 Apr 2023 09:54:51 +0200 Subject: [PATCH 01/13] [SLS-14] Updated Dockerfile --- .github/workflows/release.yaml | 19 +++++++++++++++++++ Dockerfile | 17 +++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 Dockerfile diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 66214606..0b4320a2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -2,6 +2,13 @@ name: Publish package to GitHub Packages on: release: types: [created] +env: + DOCKERFILE: Dockerfile.test-only + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} jobs: publish: runs-on: ubuntu-latest @@ -39,3 +46,15 @@ jobs: arguments: publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..00e23516 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM eclipse-temurin:11-jdk-alpine as build + +WORKDIR /build +COPY ./samples/spring . + +RUN ./gradlew bootJar + +FROM eclipse-temurin:11-jdk-alpine as runtime + +WORKDIR /app +COPY --from=build /build/build/libs/*.jar /app/app.jar + +RUN addgroup -S appuser && adduser -S appuser -G appuser +USER appuser + +EXPOSE 8080 +ENTRYPOINT [ "java","-jar","/app/app.jar" ] \ No newline at end of file From 223217e659694e1e8be84d4dac8e3416144887a1 Mon Sep 17 00:00:00 2001 From: Alessio Cialini Date: Wed, 26 Apr 2023 10:14:55 +0200 Subject: [PATCH 02/13] [SLS-14] Updated Dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 00e23516..9d5095d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ FROM eclipse-temurin:11-jdk-alpine as build WORKDIR /build COPY ./samples/spring . +RUN chmod +x ./gradlew RUN ./gradlew bootJar FROM eclipse-temurin:11-jdk-alpine as runtime From 4adfe97020d09fc2101d56a3fe3b542f4fe10bbb Mon Sep 17 00:00:00 2001 From: Alessio Cialini Date: Wed, 26 Apr 2023 10:18:48 +0200 Subject: [PATCH 03/13] [SLS-14] Updated LollipopConsumerSample --- .../java/it/pagopa/tech/sample/LollipopConsumerSample.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/samples/simple/src/main/java/it/pagopa/tech/sample/LollipopConsumerSample.java b/samples/simple/src/main/java/it/pagopa/tech/sample/LollipopConsumerSample.java index 617e2de9..8ebab761 100644 --- a/samples/simple/src/main/java/it/pagopa/tech/sample/LollipopConsumerSample.java +++ b/samples/simple/src/main/java/it/pagopa/tech/sample/LollipopConsumerSample.java @@ -17,7 +17,9 @@ import it.pagopa.tech.lollipop.consumer.idp.IdpCertProviderFactory; import it.pagopa.tech.lollipop.consumer.idp.client.simple.IdpCertSimpleClientConfig; import it.pagopa.tech.lollipop.consumer.idp.client.simple.IdpCertSimpleClientProvider; +import it.pagopa.tech.lollipop.consumer.idp.client.simple.storage.SimpleIdpCertStorageProvider; import it.pagopa.tech.lollipop.consumer.idp.impl.IdpCertProviderFactoryImpl; +import it.pagopa.tech.lollipop.consumer.idp.storage.IdpCertStorageConfig; import it.pagopa.tech.lollipop.consumer.logger.LollipopLoggerServiceFactory; import it.pagopa.tech.lollipop.consumer.logger.impl.LollipopLogbackLoggerServiceFactory; import it.pagopa.tech.lollipop.consumer.model.CommandResult; @@ -89,7 +91,8 @@ private static LollipopConsumerFactoryHelper buildLollipopConsumerFactoryHelper( LollipopConsumerRequestConfig.builder().build()); AssertionStorageProvider assertionStorageProvider = new SimpleAssertionStorageProvider(); IdpCertProviderFactory idpCertProviderFactory = new IdpCertProviderFactoryImpl( - new IdpCertSimpleClientProvider(IdpCertSimpleClientConfig.builder().build())); + new IdpCertSimpleClientProvider(IdpCertSimpleClientConfig.builder().build(), + new SimpleIdpCertStorageProvider(), new IdpCertStorageConfig())); AssertionClientProvider assertionClientProvider = new AssertionSimpleClientProvider(AssertionSimpleClientConfig.builder().build()); AssertionServiceFactory assertionServiceFactory = new AssertionServiceFactoryImpl( From 4ed6b926c156f91d903224ff38145d1e23e5f8ef Mon Sep 17 00:00:00 2001 From: Alessio Cialini Date: Wed, 26 Apr 2023 10:42:38 +0200 Subject: [PATCH 04/13] [SLS-14] Updated build.gradle --- build.gradle | 2 +- samples/spring/build.gradle | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index a76c3f38..661da641 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ repositories { } allprojects { - version = "1.0.0-RC1" + version = "1.0.0-SNAPSHOT" group = 'it.pagopa.tech.lollipop-consumer-java-sdk' sourceCompatibility = '11' targetCompatibility = '11' diff --git a/samples/spring/build.gradle b/samples/spring/build.gradle index 0d766de3..242f7897 100644 --- a/samples/spring/build.gradle +++ b/samples/spring/build.gradle @@ -35,11 +35,11 @@ repositories { } dependencies { - implementation 'it.pagopa.tech.lollipop-consumer-java-sdk:core:1.0.0-RC1' - implementation 'it.pagopa.tech.lollipop-consumer-java-sdk:assertion-rest-client-native:1.0.0-RC1' - implementation 'it.pagopa.tech.lollipop-consumer-java-sdk:identity-service-rest-client-native:1.0.0-RC1' - implementation 'it.pagopa.tech.lollipop-consumer-java-sdk:http-verifier:1.0.0-RC1' - implementation 'it.pagopa.tech.lollipop-consumer-java-sdk:spring-impl:1.0.0-RC1' + implementation 'it.pagopa.tech.lollipop-consumer-java-sdk:core:1.0.0-SNAPSHOT' + implementation 'it.pagopa.tech.lollipop-consumer-java-sdk:assertion-rest-client-native:1.0.0-SNAPSHOT' + implementation 'it.pagopa.tech.lollipop-consumer-java-sdk:identity-service-rest-client-native:1.0.0-SNAPSHOT' + implementation 'it.pagopa.tech.lollipop-consumer-java-sdk:http-verifier:1.0.0-SNAPSHOT' + implementation 'it.pagopa.tech.lollipop-consumer-java-sdk:spring-impl:1.0.0-SNAPSHOT' implementation 'org.mock-server:mockserver-netty:5.15.0' implementation 'org.springframework.boot:spring-boot-starter-web' From 8121349dfdd6134bb91a44292534692067250e7e Mon Sep 17 00:00:00 2001 From: Alessio Cialini Date: Wed, 26 Apr 2023 10:48:04 +0200 Subject: [PATCH 05/13] [SLS-14] Updated build.gradle --- samples/spring/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/spring/build.gradle b/samples/spring/build.gradle index 242f7897..5d2b7e8a 100644 --- a/samples/spring/build.gradle +++ b/samples/spring/build.gradle @@ -5,7 +5,7 @@ plugins { } group = 'it.pagopa.tech.lollipop.consumer.samples' -version = '1.0.0-RC1' +version = '1.0.0-SNAPSHOT' sourceCompatibility = '11' configurations { From 0ed69bd9b921059b2c82f69d7a479776ce799580 Mon Sep 17 00:00:00 2001 From: Alessio Cialini Date: Wed, 26 Apr 2023 10:57:25 +0200 Subject: [PATCH 06/13] [SLS-14] Updated LollipopConsumerCommandBuilderImplTest --- .../command/impl/LollipopConsumerCommandBuilderImplTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/test/java/it/pagopa/tech/lollipop/consumer/command/impl/LollipopConsumerCommandBuilderImplTest.java b/core/src/test/java/it/pagopa/tech/lollipop/consumer/command/impl/LollipopConsumerCommandBuilderImplTest.java index 80a338a6..d3e60706 100644 --- a/core/src/test/java/it/pagopa/tech/lollipop/consumer/command/impl/LollipopConsumerCommandBuilderImplTest.java +++ b/core/src/test/java/it/pagopa/tech/lollipop/consumer/command/impl/LollipopConsumerCommandBuilderImplTest.java @@ -28,7 +28,7 @@ void beforeAll() { void testThatCreatsCommand() { assertThat( lollipopConsumerCommandBuilder.createCommand( - LollipopConsumerRequest.builder().build())) + Mockito.mock(LollipopConsumerRequest.class))) .isInstanceOf(LollipopConsumerCommand.class); } } From 43868d8006d458b9da0eb96cb7081db30157026d Mon Sep 17 00:00:00 2001 From: Alessio Cialini Date: Wed, 26 Apr 2023 11:09:58 +0200 Subject: [PATCH 07/13] [SLS-14] Updated SampleApplicationTests --- .../tech/lollipop/consumer/sample/SampleApplicationTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/spring/src/test/java/it/pagopa/tech/lollipop/consumer/sample/SampleApplicationTests.java b/samples/spring/src/test/java/it/pagopa/tech/lollipop/consumer/sample/SampleApplicationTests.java index aeec9dc0..694fd01f 100644 --- a/samples/spring/src/test/java/it/pagopa/tech/lollipop/consumer/sample/SampleApplicationTests.java +++ b/samples/spring/src/test/java/it/pagopa/tech/lollipop/consumer/sample/SampleApplicationTests.java @@ -1,4 +1,4 @@ -package test.java.it.pagopa.tech.lollipop.consumer.sample; +package it.pagopa.tech.lollipop.consumer.sample; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; From 711e13989c2c34cf8974f5051d1f85d047fccc1b Mon Sep 17 00:00:00 2001 From: Alessio Cialini Date: Wed, 26 Apr 2023 11:33:08 +0200 Subject: [PATCH 08/13] [SLS-14] Updated Dockerfile and release.yaml --- .github/workflows/release.yaml | 3 +++ Dockerfile | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0b4320a2..5cf0e0f9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -53,6 +53,9 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push Docker image uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + secrets: | + "GITHUB_ACTOR=${{ secrets.GITHUB_ACTOR }}" + "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" with: context: . push: true diff --git a/Dockerfile b/Dockerfile index 9d5095d2..e3e0e363 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,11 @@ FROM eclipse-temurin:11-jdk-alpine as build WORKDIR /build COPY ./samples/spring . +RUN --mount=type=secret,id=GITHUB_TOKEN \ + --mount=type=secret,id=GITHUB_ACTOR \ + export GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) && \ + export GITHUB_ACTOR=$(cat /run/secrets/GITHUB_ACTOR) + RUN chmod +x ./gradlew RUN ./gradlew bootJar From 23da33e1c4404cbc02c1bafaafe0968aa2478ccb Mon Sep 17 00:00:00 2001 From: Alessio Cialini Date: Wed, 26 Apr 2023 11:33:39 +0200 Subject: [PATCH 09/13] [SLS-14] Updated Dockerfile and release.yaml --- .github/workflows/release.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5cf0e0f9..f5f183fc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -53,11 +53,11 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push Docker image uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 - secrets: | - "GITHUB_ACTOR=${{ secrets.GITHUB_ACTOR }}" - "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" with: context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + secrets: | + "GITHUB_ACTOR=${{ secrets.GITHUB_ACTOR }}" + "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" From 94ba7c304563198e3c2ffa01a7ae1f8c3d0601e8 Mon Sep 17 00:00:00 2001 From: Alessio Cialini Date: Wed, 26 Apr 2023 11:36:43 +0200 Subject: [PATCH 10/13] [SLS-14] Updated Dockerfile and release.yaml --- .github/workflows/release.yaml | 4 ++++ Dockerfile | 8 -------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f5f183fc..3ae0b311 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -46,6 +46,10 @@ jobs: arguments: publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Make spring sample gradlew executable + run: chmod +x ./samples/spring/gradlew + - name: Run build with Gradle Wrapper on Spring Sample + run: ./samples/spring/gradlew bootJar - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 diff --git a/Dockerfile b/Dockerfile index e3e0e363..7dfb8d45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,14 +3,6 @@ FROM eclipse-temurin:11-jdk-alpine as build WORKDIR /build COPY ./samples/spring . -RUN --mount=type=secret,id=GITHUB_TOKEN \ - --mount=type=secret,id=GITHUB_ACTOR \ - export GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) && \ - export GITHUB_ACTOR=$(cat /run/secrets/GITHUB_ACTOR) - -RUN chmod +x ./gradlew -RUN ./gradlew bootJar - FROM eclipse-temurin:11-jdk-alpine as runtime WORKDIR /app From d1af92868083cd45a5dd9eafe5ff2e6dc026f4ca Mon Sep 17 00:00:00 2001 From: Alessio Cialini Date: Wed, 26 Apr 2023 11:46:43 +0200 Subject: [PATCH 11/13] [SLS-14] Updated release.yaml --- .github/workflows/release.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3ae0b311..2e4c1d65 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -47,9 +47,17 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Make spring sample gradlew executable - run: chmod +x ./samples/spring/gradlew + run: chmod +x .gradlew + working-directory: ./samples/spring - name: Run build with Gradle Wrapper on Spring Sample - run: ./samples/spring/gradlew bootJar + run: ./gradlew bootJar + working-directory: ./samples/spring + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 From 2e2e328225716d605dbe6d4030bb9797ddbb06a4 Mon Sep 17 00:00:00 2001 From: Alessio Cialini Date: Wed, 26 Apr 2023 12:03:55 +0200 Subject: [PATCH 12/13] [SLS-14] Updated release.yaml --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2e4c1d65..94887c65 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -47,7 +47,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Make spring sample gradlew executable - run: chmod +x .gradlew + run: chmod +x ./gradlew working-directory: ./samples/spring - name: Run build with Gradle Wrapper on Spring Sample run: ./gradlew bootJar From be1ec8816f215e6a02b81eb6dc237b6845530500 Mon Sep 17 00:00:00 2001 From: Alessio Cialini Date: Wed, 26 Apr 2023 12:17:27 +0200 Subject: [PATCH 13/13] [SLS-14] Updated build.gradle --- build.gradle | 2 +- samples/spring/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 661da641..a76c3f38 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ repositories { } allprojects { - version = "1.0.0-SNAPSHOT" + version = "1.0.0-RC1" group = 'it.pagopa.tech.lollipop-consumer-java-sdk' sourceCompatibility = '11' targetCompatibility = '11' diff --git a/samples/spring/build.gradle b/samples/spring/build.gradle index 5d2b7e8a..242f7897 100644 --- a/samples/spring/build.gradle +++ b/samples/spring/build.gradle @@ -5,7 +5,7 @@ plugins { } group = 'it.pagopa.tech.lollipop.consumer.samples' -version = '1.0.0-SNAPSHOT' +version = '1.0.0-RC1' sourceCompatibility = '11' configurations {