diff --git a/.github/workflows/CD - Deploy - Auth Service.yml b/.github/workflows/CD - Deploy - Auth Service.yml new file mode 100644 index 0000000..81c158f --- /dev/null +++ b/.github/workflows/CD - Deploy - Auth Service.yml @@ -0,0 +1,31 @@ +# ========================================= CD - Deploy - Auth Service ========================================= + +name: CD - Deploy - Auth Service + +on: + push: + branches: + - production + paths: + - "auth/**" + +jobs: + Auth-Service-CD-Pipeline: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + # Build Image and push to Docker registry + - run: cd auth && docker build -t alwinsimon/bookmyseat-auth . + - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - run: docker push alwinsimon/bookmyseat-auth + + # Restart Deployment in K8s cluster deployed in Digital Ocean + - uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - run: doctl kubernetes cluster kubeconfig save ${{ secrets.DIGITALOCEAN_CLUSTER_ID }} + - run: kubectl rollout restart deployment auth-depl diff --git a/.github/workflows/CD - Deploy - Client Service.yml b/.github/workflows/CD - Deploy - Client Service.yml new file mode 100644 index 0000000..3cc0897 --- /dev/null +++ b/.github/workflows/CD - Deploy - Client Service.yml @@ -0,0 +1,31 @@ +# ========================================= CD - Deploy - Client Service ========================================= + +name: CD - Deploy - Client Service + +on: + push: + branches: + - production + paths: + - "client/**" + +jobs: + Client-Service-CD-Pipeline: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + # Build Image and push to Docker registry + - run: cd client && docker build -t alwinsimon/bookmyseat-client . + - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - run: docker push alwinsimon/bookmyseat-client + + # Restart Deployment in K8s cluster deployed in Digital Ocean + - uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - run: doctl kubernetes cluster kubeconfig save ${{ secrets.DIGITALOCEAN_CLUSTER_ID }} + - run: kubectl rollout restart deployment client-depl diff --git a/.github/workflows/CD - Deploy - Expiration Service.yml b/.github/workflows/CD - Deploy - Expiration Service.yml new file mode 100644 index 0000000..93dd187 --- /dev/null +++ b/.github/workflows/CD - Deploy - Expiration Service.yml @@ -0,0 +1,31 @@ +# ========================================= CD - Deploy - Expiration Service ========================================= + +name: CD - Deploy - Expiration Service + +on: + push: + branches: + - production + paths: + - "expiration/**" + +jobs: + Expiration-Service-CD-Pipeline: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + # Build Image and push to Docker registry + - run: cd expiration && docker build -t alwinsimon/bookmyseat-expiration . + - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - run: docker push alwinsimon/bookmyseat-expiration + + # Restart Deployment in K8s cluster deployed in Digital Ocean + - uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - run: doctl kubernetes cluster kubeconfig save ${{ secrets.DIGITALOCEAN_CLUSTER_ID }} + - run: kubectl rollout restart deployment expiration-depl diff --git a/.github/workflows/CD - Deploy - Manifests.yml b/.github/workflows/CD - Deploy - Manifests.yml new file mode 100644 index 0000000..d3af011 --- /dev/null +++ b/.github/workflows/CD - Deploy - Manifests.yml @@ -0,0 +1,22 @@ +# ========================================= CD - Deploy - Manifests ========================================= + +name: CD - Deploy - Manifests + +on: + push: + branches: + - production + paths: + - "infra/**" + +jobs: + Deploy-Manifests-CD-Pipeline: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - run: doctl kubernetes cluster kubeconfig save ${{ secrets.DIGITALOCEAN_CLUSTER_ID }} + - run: kubectl apply -f infra/k8s && kubectl apply -f infra/k8s-prod diff --git a/.github/workflows/CD - Deploy - Orders Service.yml b/.github/workflows/CD - Deploy - Orders Service.yml new file mode 100644 index 0000000..04dd690 --- /dev/null +++ b/.github/workflows/CD - Deploy - Orders Service.yml @@ -0,0 +1,31 @@ +# ========================================= CD - Deploy - Orders Service ========================================= + +name: CD - Deploy - Orders Service + +on: + push: + branches: + - production + paths: + - "orders/**" + +jobs: + Orders-Service-CD-Pipeline: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + # Build Image and push to Docker registry + - run: cd orders && docker build -t alwinsimon/bookmyseat-orders . + - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - run: docker push alwinsimon/bookmyseat-orders + + # Restart Deployment in K8s cluster deployed in Digital Ocean + - uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - run: doctl kubernetes cluster kubeconfig save ${{ secrets.DIGITALOCEAN_CLUSTER_ID }} + - run: kubectl rollout restart deployment orders-depl diff --git a/.github/workflows/CD - Deploy - Payments Service.yml b/.github/workflows/CD - Deploy - Payments Service.yml new file mode 100644 index 0000000..65be0c7 --- /dev/null +++ b/.github/workflows/CD - Deploy - Payments Service.yml @@ -0,0 +1,31 @@ +# ========================================= CD - Deploy - Payments Service ========================================= + +name: CD - Deploy - Payments Service + +on: + push: + branches: + - production + paths: + - "payments/**" + +jobs: + Payments-Service-CD-Pipeline: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + # Build Image and push to Docker registry + - run: cd payments && docker build -t alwinsimon/bookmyseat-payments . + - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - run: docker push alwinsimon/bookmyseat-payments + + # Restart Deployment in K8s cluster deployed in Digital Ocean + - uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - run: doctl kubernetes cluster kubeconfig save ${{ secrets.DIGITALOCEAN_CLUSTER_ID }} + - run: kubectl rollout restart deployment payments-depl diff --git a/.github/workflows/CD - Deploy - Tickets Service.yml b/.github/workflows/CD - Deploy - Tickets Service.yml new file mode 100644 index 0000000..d54ba7d --- /dev/null +++ b/.github/workflows/CD - Deploy - Tickets Service.yml @@ -0,0 +1,31 @@ +# ========================================= CD - Deploy - Tickets Service ========================================= + +name: CD - Deploy - Tickets Service + +on: + push: + branches: + - production + paths: + - "tickets/**" + +jobs: + Tickets-Service-CD-Pipeline: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + # Build Image and push to Docker registry + - run: cd tickets && docker build -t alwinsimon/bookmyseat-tickets . + - run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - run: docker push alwinsimon/bookmyseat-tickets + + # Restart Deployment in K8s cluster deployed in Digital Ocean + - uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - run: doctl kubernetes cluster kubeconfig save ${{ secrets.DIGITALOCEAN_CLUSTER_ID }} + - run: kubectl rollout restart deployment tickets-depl diff --git a/.github/workflows/CI - Tests - Auth Service.yml b/.github/workflows/CI - Tests - Auth Service.yml new file mode 100644 index 0000000..b51eb10 --- /dev/null +++ b/.github/workflows/CI - Tests - Auth Service.yml @@ -0,0 +1,16 @@ +# ========================================= CI - Tests - Auth Service ========================================= + +name: CI - Tests - Auth Service + +on: + pull_request: + paths: + - "auth/**" + +jobs: + Auth-Service-Pre-Integration-Tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - run: cd auth && npm install && npm run test:ci diff --git a/.github/workflows/CI - Tests - Orders Service.yml b/.github/workflows/CI - Tests - Orders Service.yml new file mode 100644 index 0000000..a36e407 --- /dev/null +++ b/.github/workflows/CI - Tests - Orders Service.yml @@ -0,0 +1,16 @@ +# ========================================= CI - Tests - Orders Service ========================================= + +name: CI - Tests - Orders Service + +on: + pull_request: + paths: + - "orders/**" + +jobs: + Orders-Service-Pre-Integration-Tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - run: cd orders && npm install && npm run test:ci diff --git a/.github/workflows/CI - Tests - Payments Service.yml b/.github/workflows/CI - Tests - Payments Service.yml new file mode 100644 index 0000000..258438a --- /dev/null +++ b/.github/workflows/CI - Tests - Payments Service.yml @@ -0,0 +1,16 @@ +# ========================================= CI - Tests - Payments Service ========================================= + +name: CI - Tests - Payments Service + +on: + pull_request: + paths: + - "payments/**" + +jobs: + Payments-Service-Pre-Integration-Tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - run: cd payments && npm install && npm run test:ci diff --git a/.github/workflows/CI - Tests - Tickets Service.yml b/.github/workflows/CI - Tests - Tickets Service.yml new file mode 100644 index 0000000..2d8fb29 --- /dev/null +++ b/.github/workflows/CI - Tests - Tickets Service.yml @@ -0,0 +1,16 @@ +# ========================================= CI - Tests - Tickets Service ========================================= + +name: CI - Tests - Tickets Service + +on: + pull_request: + paths: + - "tickets/**" + +jobs: + Tickets-Service-Pre-Integration-Tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - run: cd tickets && npm install && npm run test:ci diff --git a/auth/package.json b/auth/package.json index 604068e..b1cfa63 100644 --- a/auth/package.json +++ b/auth/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "start": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts", - "test": "jest --watchAll --no-cache" + "test": "jest --watchAll --no-cache", + "test:ci": "jest" }, "jest": { "preset": "ts-jest", diff --git a/auth/src/index.ts b/auth/src/index.ts index 254f16a..6bcdcef 100644 --- a/auth/src/index.ts +++ b/auth/src/index.ts @@ -3,7 +3,6 @@ import mongoose from "mongoose"; import { app } from "./app"; const startServer = async () => { - const PORT = 3000; const SERVICE_NAME = "AUTH"; diff --git a/client/pages/index.js b/client/pages/index.js index 2401514..2023e0a 100644 --- a/client/pages/index.js +++ b/client/pages/index.js @@ -6,7 +6,7 @@ const IndexPage = ({ currentUser, tickets }) => { <>

Landing Page


-
Signed Out
+
Signed Out.
); } diff --git a/infra/k8s/ingress-srv.yaml b/infra/k8s-dev/ingress-srv.yaml similarity index 100% rename from infra/k8s/ingress-srv.yaml rename to infra/k8s-dev/ingress-srv.yaml diff --git a/infra/k8s-prod/ingress-srv.yaml b/infra/k8s-prod/ingress-srv.yaml new file mode 100644 index 0000000..3defdde --- /dev/null +++ b/infra/k8s-prod/ingress-srv.yaml @@ -0,0 +1,47 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ingress-service + annotations: + kubernetes.io/ingress.class: nginx + nginx.ingress.kubernetes.io/use-regex: "true" +spec: + rules: + - host: bookmyseat.dev + http: + paths: + - path: /api/users/?(.*) + pathType: Prefix + backend: + service: + name: auth-srv + port: + number: 3000 + - path: /api/tickets/?(.*) + pathType: Prefix + backend: + service: + name: tickets-srv + port: + number: 3000 + - path: /api/orders/?(.*) + pathType: Prefix + backend: + service: + name: orders-srv + port: + number: 3000 + - path: /api/payments/?(.*) + pathType: Prefix + backend: + service: + name: payments-srv + port: + number: 3000 + - path: /?(.*) + pathType: Prefix + backend: + service: + name: client-srv + port: + number: 3000 diff --git a/orders/package.json b/orders/package.json index 010e589..0860052 100644 --- a/orders/package.json +++ b/orders/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "start": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts", - "test": "jest --watchAll --no-cache" + "test": "jest --watchAll --no-cache", + "test:ci": "jest" }, "jest": { "preset": "ts-jest", diff --git a/payments/package.json b/payments/package.json index 71f5232..05529c6 100644 --- a/payments/package.json +++ b/payments/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "start": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts", - "test": "jest --watchAll --no-cache" + "test": "jest --watchAll --no-cache", + "test:ci": "jest" }, "jest": { "preset": "ts-jest", diff --git a/skaffold.yaml b/skaffold.yaml index ef60155..4c6dab9 100644 --- a/skaffold.yaml +++ b/skaffold.yaml @@ -4,6 +4,7 @@ deploy: kubectl: manifests: - ./infra/k8s/* + - ./infra/k8s-dev/* build: local: push: true diff --git a/tickets/package.json b/tickets/package.json index f885d32..0b0a294 100644 --- a/tickets/package.json +++ b/tickets/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "start": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts", - "test": "jest --watchAll --no-cache" + "test": "jest --watchAll --no-cache", + "test:ci": "jest" }, "jest": { "preset": "ts-jest",