Skip to content

Commit

Permalink
Added app.yml for CI pipeline and implemented docker
Browse files Browse the repository at this point in the history
  • Loading branch information
AliRizaAynaci committed Jul 9, 2024
1 parent 178f24b commit f1c1360
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/app.yml
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
14 changes: 14 additions & 0 deletions Dockerfile
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"]
26 changes: 26 additions & 0 deletions docker-compose.yml
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

0 comments on commit f1c1360

Please sign in to comment.