Skip to content

Commit fe50440

Browse files
committed
Added Docker and Jar file pipeline
Modified the ci cd pipeline to include the final requirements for the assignment
1 parent 8cbd19d commit fe50440

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

.github/workflows/main.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,19 @@ jobs:
3838

3939
- name: Run Unit Tests (JUnit)
4040
run: mvn test
41+
42+
# Build the .jar file
43+
- name: Build Jar
44+
run: mvn clean package --file pom.xml
45+
46+
# Docker Login using GitHub Secrets
47+
- name: Log in to Docker Hub
48+
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
49+
50+
# Build Docker Image
51+
- name: Build Docker Image
52+
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/my-java-app:latest .
53+
54+
# Push Docker Image to Docker Hub
55+
- name: Push Docker Image
56+
run: docker push ${{ secrets.DOCKER_USERNAME }}/my-java-app:latest

dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# use an official OpenJDK runtime as a base image
2+
FROM openjdk:17-jdk-slim
3+
4+
# set a working directory in the container
5+
WORKDIR /app
6+
7+
# Copy the built JAR file into the container
8+
COPY target/LabAssignment01Noulis-0.0.1-SNAPSHOT.jar /app/my-java-app.jar
9+
10+
EXPOSE 8080
11+
12+
# Command to run the app
13+
CMD ["java", "-jar", "/app/my-java-app.jar"]

0 commit comments

Comments
 (0)