Skip to content

Commit

Permalink
Merge branch 'chore/k8s-deploy' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondanythings committed Dec 15, 2023
2 parents 8028229 + 51294eb commit b0d84dc
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 5 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: deploy-cluster-prod
on:
push:
branches: ['develop']
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

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

- name: Build and push the Docker image
uses: docker/build-push-action@v3
with:
push: true
tags: |
ghcr.io/medici-mansion/shinnyang-server:latest
ghcr.io/medici-mansion/shinnyang-server:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
name: Deploy
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Set the Kubernetes context
uses: azure/k8s-set-context@v2
with:
method: service-account
k8s-url: https://783da7b8-3679-4834-aadf-a68204c5ebc2.vultr-k8s.com:6443
k8s-secret: ${{ secrets.KUBERNETES_SECRET }}
- name: Checkout source code
uses: actions/checkout@v3
- name: Deploy to the Kubernetes cluster
uses: azure/k8s-deploy@v1
with:
namespace: default
manifests: |
k8s/deployment.yaml
images: |
ghcr.io/medici-mansion/shinnyang-server:${{ github.sha }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ COPY . /app
WORKDIR /app

FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install

FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install
RUN pnpm run build


Expand Down
71 changes: 71 additions & 0 deletions k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: catsnewyear
spec:
replicas: 3
selector:
matchLabels:
app: catsnewyear
template:
metadata:
labels:
app: catsnewyear
spec:
containers:
- name: catsnewyear
image: ghcr.io/medici/catsnewyear-server:latest
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 3000
envFrom:
- secretRef:
name: catsnewyear-prod
# env:
# - name: NODE_ENV
# valueFrom:
# secretKeyRef:
# name: catsnewyear-prod
# key: NODE_ENV
# optional: false
# - name: PORT
# valueFrom:
# secretKeyRef:
# name: catsnewyear-prod
# key: PORT
# optional: false
# - name: DB_HOST
# valueFrom:
# secretKeyRef:
# name: catsnewyear-prod
# key: DB_HOST
# optional: false
# - name: DB_PORT
# valueFrom:
# secretKeyRef:
# name: catsnewyear-prod
# key: DB_PORT
# optional: false
# - name: DB_USER
# valueFrom:
# secretKeyRef:
# name: catsnewyear-prod
# key: DB_USER
# optional: false
# - name: DB_PWD
# valueFrom:
# secretKeyRef:
# name: catsnewyear-prod
# key: DB_PWD
# optional: false
# - name: DB_NAME
# valueFrom:
# secretKeyRef:
# name: catsnewyear-prod
# key: DB_NAME
# optional: false
imagePullSecrets:
- name: github-container-registry
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "shinnyang",
"version": "0.0.1",
"version": "0.1.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "cross-env NODE_ENV=production nest start",
"start:dev": "cross-env NODE_ENV=development nest start --watch",
"start": "NODE_ENV=production nest start",
"start:dev": "NODE_ENV=development nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
Expand Down

0 comments on commit b0d84dc

Please sign in to comment.