diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..a72eb1cf5 Binary files /dev/null and b/.DS_Store differ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..42b9409d7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,28 @@ +name: Build and Deploy +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + + - name: Build with Maven + run: ./mvnw package -B + + - name: Build Docker Image + run: docker build -t petclinic:${{ github.sha }} . + + - name: Test + run: ./mvnw test \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..b8515f0b5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM eclipse-temurin:17-jdk-jammy as builder +WORKDIR /app +COPY .mvn/ .mvn +COPY mvnw pom.xml ./ +RUN ./mvnw dependency:go-offline +COPY src ./src +RUN ./mvnw package -DskipTests + +FROM eclipse-temurin:17-jre-jammy +WORKDIR /app +COPY --from=builder /app/target/*.jar app.jar +EXPOSE 8080 +ENTRYPOINT ["java", "-jar", "app.jar"] \ No newline at end of file diff --git a/k8s/base/deployment.yaml b/k8s/base/deployment.yaml new file mode 100644 index 000000000..06b0bb99b --- /dev/null +++ b/k8s/base/deployment.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: petclinic +spec: + replicas: 1 + selector: + matchLabels: + app: petclinic + template: + metadata: + labels: + app: petclinic + spec: + containers: + - name: petclinic + image: petclinic:latest + ports: + - containerPort: 8080 + resources: + requests: + memory: "512Mi" + cpu: "250m" + limits: + memory: "1Gi" + cpu: "500m" + readinessProbe: + httpGet: + path: /actuator/health + port: 8080 + initialDelaySeconds: 30 + periodSeconds: 10 + - name: petclinic + image: petclinic:latest + imagePullPolicy: IfNotPresent \ No newline at end of file diff --git a/k8s/base/service.yaml b/k8s/base/service.yaml new file mode 100644 index 000000000..b0a5ebd8a --- /dev/null +++ b/k8s/base/service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: petclinic +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 8080 + selector: + app: petclinic \ No newline at end of file diff --git a/k8s/deployment.yml b/k8s/deployment.yml new file mode 100644 index 000000000..e69de29bb