Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Backend CI Build #118

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 28 additions & 19 deletions .github/workflows/build-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,66 @@ on:
- 'power-pay-backend/**'
- '.github/workflows/build-service.yml'

pull_request:
branches:
- '**'
paths:
- 'power-pay-backend/**'
- '.github/workflows/build-service.yml'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-backend


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/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 +78,9 @@ 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
Loading