Skip to content

Commit 5db89f7

Browse files
committed
Added Dockerfile for investment service as well as git actions for it
1 parent bc203ca commit 5db89f7

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI/CD - LoanService
2+
3+
on:
4+
push:
5+
paths:
6+
- 'investmentservice/**'
7+
branches:
8+
- main
9+
10+
jobs:
11+
build-and-deploy:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Set up JDK 17
19+
uses: actions/setup-java@v3
20+
with:
21+
java-version: '17'
22+
distribution: 'temurin'
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v2
26+
27+
- name: Login to DockerHub
28+
uses: docker/login-action@v2
29+
with:
30+
username: ${{ secrets.DOCKER_USERNAME }}
31+
password: ${{ secrets.DOCKER_PASSWORD }}
32+
33+
- name: Build and push Docker image
34+
uses: docker/build-push-action@v5
35+
with:
36+
context: .
37+
file: ./investmentservice/Dockerfile
38+
push: true
39+
tags: pratikbagm/investmentservice:latest

investmentservice/Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Stage 1: Build
2+
FROM eclipse-temurin:17-jdk-jammy AS build
3+
4+
WORKDIR /app
5+
6+
# Copy everything for Maven context
7+
COPY . .
8+
9+
# Grant permission to mvnw
10+
RUN chmod +x mvnw
11+
12+
# Download dependencies
13+
RUN ./mvnw dependency:go-offline
14+
15+
# Build the fat JAR
16+
RUN ./mvnw clean package -DskipTests
17+
18+
# Stage 2: Run
19+
FROM eclipse-temurin:17-jre-jammy
20+
21+
WORKDIR /app
22+
23+
# Copy fat JAR
24+
COPY --from=build /app/investmentservice/target/investmentservice-0.0.1-SNAPSHOT.jar app.jar
25+
26+
EXPOSE 8083
27+
28+
ENTRYPOINT ["java", "-jar", "app.jar"]

0 commit comments

Comments
 (0)