Skip to content

Commit

Permalink
feat: deploy on flagship
Browse files Browse the repository at this point in the history
  • Loading branch information
Saghen committed Feb 29, 2024
1 parent 659db38 commit 924b666
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 2 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
54 changes: 54 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Deploy
on:
push:
branches:
- main

concurrency: deploy

jobs:
build:
name: Build Docker Image
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3

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

- name: Build
uses: docker/build-push-action@v5
with:
push: true
secrets: NPM_TOKEN=${{ github.token }}
tags: |
ghcr.io/liqwid-labs/round-table:${{ github.sha }}
ghcr.io/liqwid-labs/round-table:latest
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Authenticate Flagship
uses: liqwid-labs/flagship-authenticate-action@main
with:
kubeconfig: ${{ secrets.ARGOCD_DEV_KUBECONFIG }}

- name: Deploy ArgoCD Application
run: kubectl apply -f ci/app.yaml
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ RUN apk add --no-cache libc6-compat
ENV NODE_ENV production
USER node
WORKDIR /app
COPY --chown=node package*.json .
RUN npm ci
COPY --chown=node . .
RUN yarn install
RUN yarn build
RUN npm run build

EXPOSE 3000

Expand Down
52 changes: 52 additions & 0 deletions ci/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: round-table
namespace: argocd
labels:
app.kubernetes.io/name: round-table
spec:
goTemplate: true
goTemplateOptions:
- missingkey=error
generators:
- clusters:
selector:
matchLabels:
liqwid.finance/flagship-cluster-type: sailor
liqwid.finance/flagship-env: dev
values:
network: preview
- clusters:
selector:
matchLabels:
liqwid.finance/flagship-cluster-type: sailor
liqwid.finance/flagship-env: dev
values:
network: mainnet
template:
metadata:
name: round-table-{{ .name }}-{{ .values.network }}
labels:
app.kubernetes.io/name: liqwid-api
spec:
project: tools
destination:
name: "{{ .name }}"
namespace: tools
source:
repoURL: https://github.com/Liqwid-Labs/round-table
targetRevision: "{{ .values.revision }}"
path: ci/chart
helm:
parameters:
- name: network
value: "{{ .values.network }}"
- name: name
value: "{{ .values.network }}-round-table"
- name: redis.fullnameOverride
value: "{{ .values.network }}-round-table-redis"
- name: image.tag
value: $ARGOCD_APP_REVISION
syncPolicy:
automated: {}
1 change: 1 addition & 0 deletions ci/chart/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/charts
6 changes: 6 additions & 0 deletions ci/chart/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: redis
repository: oci://registry-1.docker.io/bitnamicharts
version: 18.17.0
digest: sha256:b280704e88c7bc7396ec0e4095d08c59e040a9ee490814d1c2e7dfe59b73c6ae
generated: "2024-02-29T14:10:26.001404153-05:00"
9 changes: 9 additions & 0 deletions ci/chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: liqwid-api
description: Deployment for Liqwid API
type: application
version: 1.0.0
dependencies:
- name: redis
repository: oci://registry-1.docker.io/bitnamicharts
version: 18.17.0
39 changes: 39 additions & 0 deletions ci/chart/templates/round-table.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.name }}
labels:
app.kubernetes.io/name: {{ .Values.name }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ .Values.name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ .Values.name }}
annotations:
kubectl.kubernetes.io/default-container: round-table
spec:
containers:
- name: round-table
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: REDIS_HOST
value: {{ .Values.redis.fullnameOverride }}
{{- if eq .Values.network "preview" }}
- name: NEXT_PUBLIC_NETWORK
value: {{ .Values.network }}
{{- end }}
- name: NEXT_PUBLIC_GRAPHQL
value: {{ .Values.options.gqlUri }}
- name: NEXT_PUBLIC_SUBMIT
value: {{ .Values.options.submitUri }}
ports:
- name: http
containerPort: 3000
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
15 changes: 15 additions & 0 deletions ci/chart/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.name }}
labels:
app.kubernetes.io/name: {{ .Values.name }}
spec:
type: ClusterIP
ports:
- port: 3000
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ .Values.name }}
40 changes: 40 additions & 0 deletions ci/chart/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: round-table
network: mainnet
replicaCount: 2

options:
gqlUri: https://d.graphql-api.mainnet.dandelion.link
submitUri: https://adao.panl.org;https://submit-api.apexpool.info/api/submit/tx

image:
repository: ghcr.io/liqwid-labs/round-table
pullPolicy: IfNotPresent
tag: ""

resources:
requests:
cpu: 10m
memory: 200Mi
limits:
cpu: "1"
memory: 2Gi

redis:
fullnameOverride: round-table-redis
auth:
enabled: false
metrics:
enabled: false
sentinel:
enabled: true
replicas: 3
automateClusterRecovery: true
downAfterMilliseconds: 2000
failoverTimeout: 10000
resources:
requests:
cpu: 10m
memory: 50Mi
limits:
cpu: 500m
memory: 500Mi

0 comments on commit 924b666

Please sign in to comment.