This commit is contained in:
YouWenKee 2024-08-11 11:41:28 +08:00
parent 383edc1656
commit 291086370b
3 changed files with 56 additions and 0 deletions

50
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,50 @@
name: CI Pipeline
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up PostgreSQL
uses: harmon758/postgresql-action@v1.0.0
with:
postgresql version: '13'
postgresql db: 'petclinic'
postgresql user: 'postgres'
postgresql password: 'password'
- name: Build with Maven
run: mvn clean install
- name: Run tests
run: mvn test
- name: Build Docker image
run: docker build -t petclinic-app .
- name: Push Docker image
run: docker push your-dockerhub-username/petclinic-app

4
Dockerfile Normal file
View file

@ -0,0 +1,4 @@
FROM openjdk:17-jdk-slim
COPY target/spring-petclinic-*.jar /app/spring-petclinic.jar
ENTRYPOINT ["java", "-jar", "/app/spring-petclinic.jar"]

View file

@ -23,3 +23,5 @@ logging.level.org.springframework=INFO
# Maximum time static resources should be cached # Maximum time static resources should be cached
spring.web.resources.cache.cachecontrol.max-age=12h spring.web.resources.cache.cachecontrol.max-age=12h
server.port=8082