diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..3290e6588 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..58053c4b9 --- /dev/null +++ b/Dockerfile @@ -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"] + diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 5d3eeed32..10c5740c9 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -23,3 +23,5 @@ logging.level.org.springframework=INFO # Maximum time static resources should be cached spring.web.resources.cache.cachecontrol.max-age=12h + +server.port=8082