Skip to content

Commit

Permalink
feat: nginx conf and github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
gulam159 committed Sep 23, 2024
1 parent 242d2c9 commit 860526f
Show file tree
Hide file tree
Showing 6 changed files with 405 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/check_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Check pull requests

on:
pull_request:
branches: [main]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "18"
- name: Install dependencies
run: yarn
- name: Check format code
run: yarn prettier:check
- name: Check build code
run: yarn build
64 changes: 64 additions & 0 deletions .github/workflows/cicd_prod_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Main Portal Docker CI/CD

on:
push:
branches: [main]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "18"
cache: "npm"

- name: Checkout and build code
run: |
chmod +x ./scripts/build.sh
./scripts/build.sh
env:
TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_API_KEY }}
BRANCH: "main"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Server
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
push: true
tags: |
ghcr.io/orkes-io/orkes-portal/portal-prod:latest
ghcr.io/orkes-io/orkes-portal/portal-prod:${{ github.run_id }}
- name: Deploy Docker Image Set Context K8s
uses: azure/k8s-set-context@v3
with:
method: service-account
k8s-url: https://99167D87C0F5E61AA05B5CF10925436F.sk1.us-east-1.eks.amazonaws.com
k8s-secret: ${{ secrets.GH_ORKES_PORTAL_PROD_DEPLOY_TOKEN }}
id: setcontext

- name: Deploy Docker Image to K8s
uses: Azure/k8s-deploy@v4
with:
namespace: orkes-portal-prod
manifests: |
./kubernetes/deploy-prod.yml
images: |
ghcr.io/orkes-io/orkes-portal/portal-prod:${{ github.run_id }}
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Use an official Node.js runtime as the base image for the build stage
FROM node:18 AS build

# Set the working directory inside the container
WORKDIR /app

COPY package.json yarn.lock ./

# Install the dependencies using yarn
RUN yarn

# Copy the rest of the application files
COPY . .

# Build the Docusaurus site
RUN yarn build

# Start a new stage for the production environment
FROM nginx:stable-alpine

# Copy the built files from the build stage to the nginx html directory
COPY --from=build /app/build /usr/share/nginx/html/content

COPY nginx.conf /etc/nginx/sites-available/default

# Expose port 80 to the outside world
EXPOSE 80

# Start Nginx when the container runs
CMD ["nginx", "-g", "daemon off;"]
48 changes: 48 additions & 0 deletions kubernetes/deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: orkes-portal-prod
namespace: orkes-portal-prod
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: orkes-portal-prod
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: orkes-portal-prod
spec:
containers:
- env:
- name: random
value: "125"
image: ghcr.io/orkes-io/orkes-portal/portal-prod:local1682986204
imagePullPolicy: IfNotPresent
name: orkes-portal-prod
resources:
limits:
cpu: "1000m"
memory: 1Gi
requests:
cpu: "1000m"
memory: 1Gi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
imagePullSecrets:
- name: regcredorkesgit
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: orkes-portal-prod-sa
serviceAccountName: orkes-portal-prod-sa
terminationGracePeriodSeconds: 30
Loading

0 comments on commit 860526f

Please sign in to comment.