From 7a01e63eea565f25f2d68c3096b9b61f8c5dcaf9 Mon Sep 17 00:00:00 2001 From: ubaid4j Date: Sun, 21 Jul 2024 10:36:24 +0500 Subject: [PATCH] - build red-app --- .../{commit-stage.yml => api-gateway.yml} | 0 .github/workflows/red-app.yml | 53 +++++++++++++++++++ deployment/k8s/api-gateway/deployment.yaml | 6 +++ red-app/.dockerignore | 5 ++ red-app/Dockerfile | 12 +++++ red-app/nginx/nginx.conf | 17 ++++++ 6 files changed, 93 insertions(+) rename .github/workflows/{commit-stage.yml => api-gateway.yml} (100%) create mode 100644 .github/workflows/red-app.yml create mode 100644 red-app/.dockerignore create mode 100644 red-app/Dockerfile create mode 100644 red-app/nginx/nginx.conf diff --git a/.github/workflows/commit-stage.yml b/.github/workflows/api-gateway.yml similarity index 100% rename from .github/workflows/commit-stage.yml rename to .github/workflows/api-gateway.yml diff --git a/.github/workflows/red-app.yml b/.github/workflows/red-app.yml new file mode 100644 index 0000000..2f45ca3 --- /dev/null +++ b/.github/workflows/red-app.yml @@ -0,0 +1,53 @@ +name: Build Red App + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ubaid4j/multiple-apps-routing/red-app + VERSION: 0.0.1-SNAPSHOT + +on: + push: + paths: + - 'red-app/**' + branches: + - main + +defaults: + run: + working-directory: ./api-gateway + +jobs: + package: + name: Package and Publish + runs-on: ubuntu-24.04 + permissions: + contents: read + packages: write + security-events: write + steps: + - name: Checkout source code + uses: actions/checkout@v3 + - name: Build Container Image + run: | + docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} . + - name: OCI Image vulnerability scanning + uses: anchore/scan-action@v3 + id: scan + with: + image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} + fail-build: true + only-fixed: true + severity-cutoff: critical + - name: Upload vulnerability report + uses: github/codeql-action/upload-sarif@v3 + if: success() + with: + sarif_file: ${{ steps.scan.outputs.sarif }} + - name: Login to container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Publish container image + run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} \ No newline at end of file diff --git a/deployment/k8s/api-gateway/deployment.yaml b/deployment/k8s/api-gateway/deployment.yaml index 6e3f053..a39cd6e 100644 --- a/deployment/k8s/api-gateway/deployment.yaml +++ b/deployment/k8s/api-gateway/deployment.yaml @@ -33,6 +33,12 @@ spec: value: '80' - name: SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_CUSTOMER1_ISSUER_URI value: 'http://keycloak/realms/customer1' + - name: RED_APP_URL + value: http://red-app + - name: GREEN_APP_URL + value: http://green-app + - name: BLUE_APP_URL + value: http://blue-app livenessProbe: httpGet: path: /management/health/liveness diff --git a/red-app/.dockerignore b/red-app/.dockerignore new file mode 100644 index 0000000..0b34177 --- /dev/null +++ b/red-app/.dockerignore @@ -0,0 +1,5 @@ +node_modules +.idea +.gitignore +.angular +.vscode diff --git a/red-app/Dockerfile b/red-app/Dockerfile new file mode 100644 index 0000000..633ae5f --- /dev/null +++ b/red-app/Dockerfile @@ -0,0 +1,12 @@ +FROM node:22-alpine3.20 as build +WORKDIR /app +COPY package.json . +RUN npm install +COPY . . +RUN npm run build + +FROM nginx:alpine +COPY --from=build /app/dist/red-app/browser /usr/share/nginx/html +COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/red-app/nginx/nginx.conf b/red-app/nginx/nginx.conf new file mode 100644 index 0000000..758a646 --- /dev/null +++ b/red-app/nginx/nginx.conf @@ -0,0 +1,17 @@ +server { + + listen 80; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + error_page 500 502 503 504 /50x.html; + + location = /50x.html { + root /usr/share/nginx/html; + } + +} \ No newline at end of file