Skip to content

Commit

Permalink
fix: removed the mvn from the Dockerfile and put it inside the gh wf …
Browse files Browse the repository at this point in the history
…file
  • Loading branch information
stephane-segning committed Apr 8, 2024
1 parent 07b471d commit 0cd440a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
41 changes: 28 additions & 13 deletions .github/workflows/build-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,59 @@ env:

jobs:
build:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
defaults:
run:
working-directory: power-pay-backend

steps:
- uses: actions/checkout@v4
- name: Clone the project
uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Maven build
run: cd power-pay-backend && mvn clean package -q

run: mvn clean package -q
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: power-pay-backend
path: power-pay-backend/target/*.jar

docker-build:
if: github.event_name != 'pull_request'
needs:
- build
runs-on: ubuntu-latest
defaults:
run:
working-directory: power-pay-backend

permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4

- name: Clone the project
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: power-pay-backend
path: power-pay-backend/power-pay-backend/target

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: lowercase_name
uses: ASzc/change-string-case-action@v6
with:
string: ${{ env.IMAGE_NAME}}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
Expand All @@ -67,11 +85,8 @@ jobs:

- name: Build and push image
uses: docker/build-push-action@v5
if: github.event_name != 'pull_request'
with:
context: ./power-pay-backend
file: ./power-pay-backend/Dockerfile
push: true
push: "${{ github.ref == 'refs/heads/main' && 'true' || 'false' }}"
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

Expand Down
4 changes: 3 additions & 1 deletion power-pay-backend/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
!src
!pom.xml
!mvnw
!.mvn
!.mvn
# ignore target folder but not the jar files in it
!target/*.jar
11 changes: 1 addition & 10 deletions power-pay-backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
FROM eclipse-temurin:21-jdk as builder

WORKDIR /app

COPY . .

RUN ./mvnw clean package


FROM eclipse-temurin:21-jre-alpine

LABEL maintainer="PowerPay Team <gis-udm@adorsys.com>"
LABEL application="power-pay-backend"

ENV APP_VERSION=0.0.1-SNAPSHOT

COPY --from=builder /app/target/power-pay-backend-${APP_VERSION}.jar /app/app.jar
COPY ./target/power-pay-backend-${APP_VERSION}.jar /app/app.jar

EXPOSE 8080

Expand Down

0 comments on commit 0cd440a

Please sign in to comment.