Skip to content

Commit 389ddd4

Browse files
committed
Merge branch 'ci'
2 parents 49ff641 + f6576d9 commit 389ddd4

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

.github/workflows/ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: CI Pipeline
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
10+
app_build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: setup java
17+
uses: actions/setup-java@v3
18+
with:
19+
distribution: 'temurin'
20+
java-version: '17'
21+
22+
- name: cache maven dependencies
23+
uses: actions/cache@v3
24+
with:
25+
path: ~/.m2/repository
26+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
27+
restore-keys: |
28+
${{ runner.os }}-maven
29+
30+
- name: build project
31+
run: mvn -B clean install
32+
33+
docker_login_build_push:
34+
needs: app_build
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: login DockerHub
38+
uses: docker/login-action@v3
39+
with:
40+
username: ${{ secrets.DOCKER_USERNAME }}
41+
password: ${{ secrets.DOCKER_PASSWORD }}
42+
43+
- name: build and push docker image
44+
uses: docker/build-push-action@v4
45+
with:
46+
push: true
47+
tags: ${{ secrets.DOCKER_USERNAME }}/catalog:latest
48+
file: ./Dockerfile
49+
context: .
50+
51+
app_upload_artifact:
52+
needs: app_build
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: upload maven artifact
56+
uses: actions/upload-artifact@v3
57+
with:
58+
name: packaged-application
59+
path: target/*.jar

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# BUILD
2+
FROM eclipse-temurin:17-jdk-alpine AS build
3+
4+
WORKDIR /app
5+
6+
COPY mvnw .
7+
COPY .mvn .mvn
8+
RUN chmod +x ./mvnw
9+
10+
COPY pom.xml .
11+
RUN ./mvnw dependency:go-offline
12+
13+
COPY src src
14+
RUN ./mvnw clean install
15+
16+
# PACKAGE
17+
FROM eclipse-temurin:17-jre-alpine AS runtime
18+
19+
WORKDIR /app
20+
21+
COPY --from=build /app/target/*.jar /app/app.jar
22+
23+
EXPOSE ${APP_PORT}
24+
25+
CMD ["java", "-Dspring.profiles.active=${SPRING_PROFILE_PROD}", "-jar", "app.jar"]

0 commit comments

Comments
 (0)