Skip to content

Commit cd770f9

Browse files
committed
feat: add Dockerfile and update CI/CD workflow for Maven and Docker integration
1 parent 3b8acd0 commit cd770f9

3 files changed

Lines changed: 31 additions & 21 deletions

File tree

.github/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM amazoncorretto:17-al2023
2+
WORKDIR /app
3+
COPY target/*.jar app.jar
4+
CMD ["java", "-jar", "app.jar"]

.github/workflows/maven.yml

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3-
4-
# This workflow uses actions that are not certified by GitHub.
5-
# They are provided by a third-party and are governed by
6-
# separate terms of service, privacy policy, and support
7-
# documentation.
8-
9-
name: Java CI with Maven
1+
name: Java CI,CD with Maven
102

113
on:
124
push:
@@ -50,15 +42,28 @@ jobs:
5042
CACHE_URL: localhost
5143
CACHE_PORT: 6379
5244
steps:
53-
- name: Checkout code
54-
uses: actions/checkout@v4
55-
56-
- name: Set up JDK 17
57-
uses: actions/setup-java@v4
58-
with:
59-
java-version: '17'
60-
distribution: 'temurin'
61-
cache: maven
62-
63-
- name: Run tests
64-
run: mvn test
45+
- name: Checkout code
46+
uses: actions/checkout@v4
47+
48+
- name: Set up JDK 17
49+
uses: actions/setup-java@v4
50+
with:
51+
java-version: '17'
52+
distribution: 'corretto'
53+
cache: maven
54+
55+
- name: Run tests and build with Maven
56+
run: mvn clean package
57+
58+
- name: Log in to GitHub Container Registry
59+
uses: docker/login-action@v3
60+
with:
61+
registry: ghcr.io
62+
username: ${{ github.actor }}
63+
password: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Build Docker image
66+
run: docker build -f .github/Dockerfile -t ghcr.io/${{ github.repository_owner }}/spring-backend:latest .
67+
68+
- name: Push Docker image
69+
run: docker push ghcr.io/${{ github.repository_owner }}/spring-backend:latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ build/
3636
### Other ###
3737

3838
/public
39+
/logs

0 commit comments

Comments
 (0)