Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POI Dispute service #12

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/scripts/kustomize-apply.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
set -e # immediately fail the script on any command error

ENVIRONMENT="$1"
IMAGE="$2"
DIR=$(dirname "$0")
cd $DIR/../../.k8s/$ENVIRONMENT

kustomize edit set image $IMAGE
kustomize build | kubectl apply -f -
58 changes: 58 additions & 0 deletions .github/workflows/server-ci-cd-mainnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Production CI/CD
on:
push:
paths:
- 'server/**'
- '.k8s/**'
- '.github/**'
env:
BASE_IMAGE: ghcr.io/edgeandnode/graph-disputes-server
APP_NAME: graph-disputes-server

jobs:
build-test:
runs-on: ubuntu-latest
steps:

- name: Checkout the repo
uses: actions/checkout@v2

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

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: ./server
cache-from: type=registry,ref=${{ env.BASE_IMAGE }}:latest
cache-to: type=inline
tags: |
${{ env.BASE_IMAGE }}:${{ github.sha }}
${{ env.BASE_IMAGE }}:latest
push: true

deploy:
if: github.ref == 'refs/heads/goaaron/poi_dispute_service'
runs-on: ubuntu-latest
needs: build-test
steps:

- name: Checkout the repo
uses: actions/checkout@v2

- name: Set up kubectl
uses: google-github-actions/get-gke-credentials@main
with:
cluster_name: ${{ secrets.GCP_CLUSTER_NAME }}
location: ${{ secrets.GCP_CLUSTER_LOCATION }}
credentials: ${{ secrets.GCP_SA_KEY_PRODUCTION }}

- name: Set a new k8s image and apply the manifests
run: .github/scripts/kustomize-apply.sh mainnet $APP_NAME=$BASE_IMAGE:$GITHUB_SHA

- name: Wait for pod to be ready
run: kubectl rollout status statefulset $APP_NAME --timeout=5m
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ coverage/
.env
.DS_Store
.vscode


__pycache__/

#data files
*.csv
service-key.json
58 changes: 58 additions & 0 deletions .k8s/mainnet/backend-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: graph-disputes-server
spec:
serviceName: graph-disputes-server
replicas: 1
selector:
matchLabels:
app: graph-disputes-server
template:
metadata:
labels:
app: graph-disputes-server
spec:
imagePullSecrets:
- name: docker-registry
containers:
- name: app
image: graph-disputes-server
env:
- name: DEPLOYMENT
value: "CLOUD"
- name: DB_HOST
valueFrom:
secretKeyRef:
name: graph-disputes-server-db-credentials
key: host
- name: DB_PORT
valueFrom:
secretKeyRef:
name: graph-disputes-server-db-credentials
key: port
- name: DB_NAME
valueFrom:
secretKeyRef:
name: graph-disputes-server-db-credentials
key: name
- name: DB_USER
valueFrom:
secretKeyRef:
name: graph-disputes-server-db-credentials
key: user
- name: DB_PASS
valueFrom:
secretKeyRef:
name: graph-disputes-server-db-credentials
key: pass
volumeMounts:
- name: data-key
mountPath: /app
volumes:
- name: data-key
secret:
secretName: graph-disputes-server-data-key
items:
- key: key.json
path: service-key.json
14 changes: 14 additions & 0 deletions .k8s/mainnet/backend-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: graph-disputes-server
name: graph-disputes-server
spec:
type: LoadBalancer
ports:
- protocol: "TCP"
port: 8080
targetPort: 8080
selector:
app: graph-disputes-server
22 changes: 22 additions & 0 deletions .k8s/mainnet/frontend-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: frontend
name: frontend
spec:
selector:
matchLabels:
app: frontend
replicas: 1
template:
metadata:
labels:
app: frontend
spec:
imagePullSecrets:
- name: docker-registry
containers:
- image: "graph-disputes-frontend"
name: graph-disputes-frontend

11 changes: 11 additions & 0 deletions .k8s/mainnet/frontend-nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
upstream Backend {
server graph-disputes-server;
}

server {
listen 80;

location / {
proxy_pass http://Backend:8000/;
}
}
14 changes: 14 additions & 0 deletions .k8s/mainnet/frontend-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: frontend
name: frontend-svc
spec:
ports:
- port: 3000
protocol: TCP
targetPort: 3000
selector:
app: frontend
type: ClusterIP
5 changes: 5 additions & 0 deletions .k8s/mainnet/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- backend-server.yaml
- backend-service.yaml
4 changes: 4 additions & 0 deletions frontend/.babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
presets: [['next/babel']],
plugins: [['import', { libraryName: 'antd', style: true }]],
};
10 changes: 10 additions & 0 deletions frontend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
};
30 changes: 30 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local
15 changes: 15 additions & 0 deletions frontend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"arrowParens": "avoid",
"bracketSpacing": true,
"endOfLine": "lf",
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false
}
23 changes: 23 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:lts as dependencies
WORKDIR /dispute-frontend
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile

FROM node:lts as builder
WORKDIR /dispute-frontend
COPY . .
COPY --from=dependencies /dispute-frontend/node_modules ./node_modules
RUN yarn build

FROM node:lts as runner
WORKDIR /dispute-frontend
ENV NODE_ENV production
# If you are using a custom next.config.js file, uncomment this line.
COPY --from=builder /dispute-frontend/next.config.js ./
COPY --from=builder /dispute-frontend/public ./public
COPY --from=builder /dispute-frontend/.next ./.next
COPY --from=builder /dispute-frontend/node_modules ./node_modules
COPY --from=builder /dispute-frontend/package.json ./package.json

EXPOSE 3000
CMD ["yarn", "start"]
11 changes: 11 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
##
1. yarn install

2. Run app
# Dev
yarn dev

# Production
yarn build
yarn start

7 changes: 7 additions & 0 deletions frontend/assets/base.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import './utils/media-queries.less';
@import './resets/base.reset.less';

:root {
--color-light-gray: #f3f3f3;
--body-container-normal-background-color: var(--color-light-gray);
}
3 changes: 3 additions & 0 deletions frontend/assets/resets/base.reset.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background-color: var(--body-container-normal-background-color) !important;
}
25 changes: 25 additions & 0 deletions frontend/assets/utils/media-queries.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@screen-xs: 480px;
@screen-sm: 768px;
@screen-md: 992px;
@screen-lg: 1200px;

@screen-sm-min: @screen-sm;
@screen-md-min: @screen-md;
@screen-xs-min: @screen-xs;
@screen-lg-min: @screen-lg;

@screen-xs-max: (@screen-sm-min - 1);
@screen-sm-max: (@screen-md-min - 1);
@screen-md-max: (@screen-lg-min - 1);

@xs-and-up: ~'only screen';
@xs-only: ~'only screen and (max-width: @{screen-xs-max})';
@sm-and-up: ~'only screen and (min-width: @{screen-sm-min})';
@sm-only: ~'only screen and (min-width: @{screen-sm-min}) and (max-width: @{screen-sm-max})';
@md-and-up: ~'only screen and (min-width: @{screen-md-min})';
@md-only: ~'only screen and (min-width: @{screen-md-min}) and (max-width: @{screen-md-max})';
@lg-and-up: ~'only screen and (min-width: @{screen-lg-min})';
@lg-only: @lg-and-up;
@mobile: @xs-only;
@tablet: @sm-only;
@desktop: @md-and-up;
Loading