-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added app.yml for CI pipeline and implemented docker
- Loading branch information
1 parent
178f24b
commit f1c1360
Showing
3 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Flight Reservation CI/CD Pipeline | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
postgres: | ||
image: postgres:13 | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: password | ||
POSTGRES_DB: flightreservation | ||
ports: | ||
- 5432:5432 | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
- 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: Build with Maven | ||
run: mvn -B clean package | ||
- name: Archive Production Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: package | ||
path: target/*.jar | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
|
||
services: | ||
postgres: | ||
image: postgres:13 | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: password | ||
POSTGRES_DB: flightreservation | ||
ports: | ||
- 5432:5432 | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
- 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: Run Tests with Maven | ||
run: mvn -B verify | ||
- name: Archive Test Reports | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: test-reports | ||
path: target/surefire-reports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM openjdk:17-jdk-slim AS build | ||
|
||
COPY pom.xml mvnw ./ | ||
COPY .mvn .mvn | ||
RUN ./mvnw dependency:resolve | ||
|
||
COPY src src | ||
RUN ./mvnw package -DskipTests | ||
|
||
FROM openjdk:17-jdk-slim | ||
WORKDIR /flightreservation | ||
COPY --from=build target/*.jar flightreservation.jar | ||
|
||
ENTRYPOINT ["java", "-jar", "flightreservation.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
version: '3.9' | ||
|
||
services: | ||
app: | ||
image: 'flightreservation' | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
container_name: flightreservation | ||
ports: | ||
- "8080:8080" | ||
environment: | ||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/flightreservation | ||
- SPRING_DATASOURCE_USERNAME=postgres | ||
- SPRING_DATASOURCE_PASSWORD=password | ||
depends_on: | ||
- db | ||
|
||
db: | ||
image: postgres:13-alpine | ||
container_name: postgres | ||
environment: | ||
- POSTGRES_DB=flightreservation | ||
- POSTGRES_USER=postgres | ||
- POSTGRES_PASSWORD=password | ||
- POSTGRES_HOST_AUTH_METHOD=trust |