Skip to content

Commit

Permalink
Configure CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-perpetuallabs committed Jul 13, 2023
1 parent d3a1222 commit 762be59
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 0 deletions.
Empty file added .dockerignore
Empty file.
76 changes: 76 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: GitWorks Workbench CI/CD

on:
push:
branches:
- main

env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GAR_LOCATION: europe-west2
DEPLOYMENT_NAME: gke-gitworks-workbench
REPOSITORY: gitworks-workbench
IMAGE: gitworks-workbench

jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
runs-on: ubuntu-latest

permissions:
contents: 'read'
id-token: 'write'

steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16

- run: npm ci
- run: npm run package

- run: npm install -g @vscode/vsce
- run: vsce package
- name: Archive VSCode VSIX
uses: actions/upload-artifact@v3
with:
name: vscode-vsix
path: ./*.vsix

- run: docker build -t $GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_SHA .

- id: 'auth'
uses: 'google-github-actions/auth@v0'
with:
credentials_json: ${{ secrets.GKE_SA_KEY }}

- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0

- name: Docker configuration
run: |-
gcloud --quiet auth configure-docker $GAR_LOCATION-docker.pkg.dev
- id: 'get-credentials'
uses: 'google-github-actions/get-gke-credentials@v0'
with:
cluster_name: gitworks-workbench-autopilot-cluster
location: europe-west2

- name: Publish
run: |-
docker push "$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_SHA"
- name: Set up Kustomize
run: |-
curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
chmod u+x ./kustomize
- name: Deploy
run: |-
./kustomize edit set image LOCATION-docker.pkg.dev/PROJECT_ID/REPOSITORY/IMAGE:TAG=$GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_SHA
./kustomize build . | kubectl apply -f -
kubectl rollout status deployment/$DEPLOYMENT_NAME
kubectl get services -o wide
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:16

WORKDIR /usr/src/app

COPY . .

WORKDIR /usr/src/app/vscode-test-web

RUN export NODE_ENV=development

RUN yarn --frozen-lockfile
RUN yarn --cwd=fs-provider --frozen-lockfile
RUN yarn run compile

EXPOSE 3000

CMD [ "node", ".", "--protocol=https", "--browser=none", "--host=0.0.0.0", "--quality=insiders", "--extensionDevelopmentPath=..", "--extensionId=vscode-icons-team.vscode-icons" ]
39 changes: 39 additions & 0 deletions deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: gke-gitworks-workbench
spec:
replicas: 1
selector:
matchLabels:
app: gke-gitworks-workbench
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
minReadySeconds: 5
template:
metadata:
labels:
app: gke-gitworks-workbench
spec:
# volumes:
# - name: gitworks-workbench-storage
# emptyDir: null
# persistentVolumeClaim:
# claimName: gitworks-workbench-storage-claim
containers:
- name: gke-gitworks-workbench
image: LOCATION-docker.pkg.dev/PROJECT_ID/REPOSITORY/IMAGE:TAG
ports:
- containerPort: 3000
resources:
requests:
cpu: 2
memory: 4Gi
limits:
cpu: 16
memory: 32Gi
# volumeMounts:
# - mountPath: /var/gitworks
# name: gitworks-storage
6 changes: 6 additions & 0 deletions kustomization.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yml
- service.yml
#- storage.yml
12 changes: 12 additions & 0 deletions service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: gke-gitworks-workbench-service
spec:
type: LoadBalancer
loadBalancerIP: "34.147.140.210"
ports:
- port: 80
targetPort: 3000
selector:
app: gke-gitworks-workbench
12 changes: 12 additions & 0 deletions storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gitworks-workbench-storage-claim
spec:
accessModes:
- ReadWriteOnce
storageClassName: "standard"
volumeName: gitworks-workbench-storage
resources:
requests:
storage: 25Gi

0 comments on commit 762be59

Please sign in to comment.