Skip to content

Commit

Permalink
Merge pull request #39 from pagopa/SLS-14
Browse files Browse the repository at this point in the history
SLS-14 - Created Spring Dockerfile and publishing to Github Docker Registry
  • Loading branch information
alessio-cialini authored Apr 26, 2023
2 parents 79e6727 + be1ec88 commit ce50def
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 8 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -39,3 +46,30 @@ jobs:
arguments: publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Make spring sample gradlew executable
run: chmod +x ./gradlew
working-directory: ./samples/spring
- name: Run build with Gradle Wrapper on Spring Sample
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
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 }}
secrets: |
"GITHUB_ACTOR=${{ secrets.GITHUB_ACTOR }}"
"GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}"
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM eclipse-temurin:11-jdk-alpine as build

WORKDIR /build
COPY ./samples/spring .

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" ]
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void beforeAll() {
void testThatCreatsCommand() {
assertThat(
lollipopConsumerCommandBuilder.createCommand(
LollipopConsumerRequest.builder().build()))
Mockito.mock(LollipopConsumerRequest.class)))
.isInstanceOf(LollipopConsumerCommand.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions samples/spring/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit ce50def

Please sign in to comment.