diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e85e98..184e881 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,35 +19,23 @@ env: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on + maven-tests: runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 8.0.232 - - name: Set up Maven - uses: stCarolas/setup-maven@v4 - with: - maven-version: 3.6.3 - - name: Cache Maven packages - uses: actions/cache@v2 + - uses: actions/checkout@v3 + - name: Set up JDK 8 + uses: actions/setup-java@v3 with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - uses: s4u/maven-settings-action@v2.2.0 - + java-version: '8' + distribution: 'adopt' + cache: maven + - name: Build with Maven - run: mvn -P 'github-packages' install -DskipTests + run: mvn --batch-mode --update-snapshots package + docker-build-publish: + runs-on: ubuntu-latest + steps: - name: Checkout code uses: actions/checkout@v2 @@ -67,17 +55,12 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Build Docker image + - name: Build and Publish Docker image uses: docker/build-push-action@v2 with: context: . - push: false - tags: ghcr.io/isanteplus/openhim-mediator-xds:ci - load: true - build-args: | - USERNAME=${{ github.actor }} - TOKEN=${{ secrets.GITHUB_TOKEN }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} cache-from: type=inline,ref=user/app:buildcache cache-to: type=inline,ref=user/app:buildcache,mode=max - - \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 3cdbefd..af0c987 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,19 @@ # build stage build the jar with all our resources -FROM openjdk:8-jdk as build +FROM maven:3.6-jdk-8 as build -VOLUME /tmp -WORKDIR / +WORKDIR /app -ADD . . +ADD pom.xml ./ -RUN apt-get update -RUN apt-get install -y maven -RUN mvn clean install -DskipTests +RUN mvn verify -COPY mediator-xds-1.0.3-jar-with-dependencies.jar /root/mediator-xds-1.0.3-jar-with-dependencies.jar +ADD src ./ -ENTRYPOINT java -jar mediator-xds-1.0.3-jar-with-dependencies.jar --conf mediator.properties +RUN mvn clean package -DskipTests + +FROM openjdk:8-jdk as run + +COPY --from=build /app/target/mediator-xds-1.0.3-jar-with-dependencies.jar /mediator-xds-1.0.3-jar-with-dependencies.jar +COPY --from=build /app/src/main/resources/mediator.properties /mediator.properties + +ENTRYPOINT java -jar /mediator-xds-1.0.3-jar-with-dependencies.jar --conf /mediator.properties