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

Add (devops): Build and deploy development environment #203

Merged
merged 2 commits into from
Dec 12, 2022
Merged
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
79 changes: 79 additions & 0 deletions .github/workflows/publish-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Publish release to development environment

on:
workflow_dispatch:
push:
branches:
- dev

jobs:
publish:
runs-on: ubuntu-latest
environment: development

steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build new image and push
run: |
make \
build-docker \
push-image
env:
LATEST_TAG: latest
IMAGE_NAME: eden-proxy-webapp-dev
NEXT_PUBLIC_UAL_APP_NAME: 'edensmartprx'
NEXT_PUBLIC_UAL_API_PROTOCOL: 'https'
NEXT_PUBLIC_UAL_API_HOST: ${{ secrets.DEV_NEXT_PUBLIC_UAL_API_HOST }}
NEXT_PUBLIC_UAL_API_PORT: '443'
NEXT_PUBLIC_UAL_CHAIN_ID: ${{ secrets.DEV_NEXT_PUBLIC_UAL_CHAIN_ID }}
NEXT_PUBLIC_AA_API_HOST: ${{ secrets.DEV_NEXT_PUBLIC_AA_API_HOST }}
NEXT_PUBLIC_GENESISEDEN_CONTRACT: genesis.eden
NEXT_PUBLIC_EDENSMARTPROXY_CONTRACT: edensmartprx
NEXT_PUBLIC_MYVOTEEOSDAO_CONTRACT: myvoteeosdao
NEXT_PUBLIC_PRODUCERS_INFO_API_URL: https://graphql-jungle.antelope.tools/api/rest/get-producers-info
EOSRATE_GET_STATS_URL: ${{ secrets.DEV_EOSRATE_GET_STATS_URL }}
EOSRATE_GET_STATS_USER: ${{ secrets.DEV_EOSRATE_GET_STATS_USER }}
EOSRATE_GET_STATS_PASSWORD: ${{ secrets.DEV_EOSRATE_GET_STATS_PASSWORD }}

- name: Build voter image and push
run: |
make \
build-docker-voter \
push-image-voter
env:
IMAGE_NAME_VOTER: proxy-voter-dev

- name: Build kubernetes files
id: build_kubernetes_files
run: |
make \
build-kubernetes
env:
LATEST_TAG: latest
IMAGE_NAME: eden-proxy-webapp-dev
IMAGE_NAME_VOTER: proxy-voter-dev
ENVIRONMENT: dev
EOS_API_ENDPOINT: 'https://jungle.edenia.cloud'
EOS_API_CHAIN_ID: '73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d'
EOS_VOTER_ACCOUNT: 'edensmartprx'
EOS_VOTER_PERMISSION: 'proxyvote'
EOS_VOTER_PRIVATE_KEY: ${{ secrets.DEV_EOS_VOTER_PRIVATE_KEY }}
EOS_PROXY_ACCOUNT: 'edensmartprx'

- name: Setup and deploy kubernetes environment
uses: steebchen/[email protected]
env:
KUBE_CONFIG_DATA: ${{ secrets.DEV_KUBE_CONFIG_DATA }}
NAMESPACE: edenproxy
K8S_BUILD_DIR: build_k8s
with:
args: version && make deploy-kubernetes
8 changes: 7 additions & 1 deletion .github/workflows/publish-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
push-image
env:
LATEST_TAG: latest
IMAGE_NAME: eden-proxy-webapp
NEXT_PUBLIC_UAL_APP_NAME: 'edensmartprx'
NEXT_PUBLIC_UAL_API_PROTOCOL: 'https'
NEXT_PUBLIC_UAL_API_HOST: ${{ secrets.NEXT_PUBLIC_UAL_API_HOST }}
Expand All @@ -47,6 +48,8 @@ jobs:
make \
build-docker-voter \
push-image-voter
env:
IMAGE_NAME_VOTER: proxy-voter

- name: Build kubernetes files
id: build_kubernetes_files
Expand All @@ -55,6 +58,9 @@ jobs:
build-kubernetes
env:
LATEST_TAG: latest
IMAGE_NAME: eden-proxy-webapp
IMAGE_NAME_VOTER: proxy-voter
ENVIRONMENT: pdn
EOS_API_ENDPOINT: 'https://api.eosn.io'
EOS_API_CHAIN_ID: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906'
EOS_VOTER_ACCOUNT: 'edensmartprx'
Expand All @@ -76,4 +82,4 @@ jobs:
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
prerelease: false
File renamed without changes.
31 changes: 31 additions & 0 deletions k8s-dev/ingress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: http
spec:
entryPoints:
- web
routes:
- kind: Rule
match: Host(`proxy.edenia.cloud`)
services:
- kind: Service
name: edenproxy
port: 3000
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: https
spec:
entryPoints:
- websecure
routes:
- kind: Rule
match: Host(`proxy.edenia.cloud`)
services:
- kind: Service
name: edenproxy
port: 3000
tls:
certResolver: myresolver
File renamed without changes.
File renamed without changes.
40 changes: 40 additions & 0 deletions k8s-pdn/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: edenproxy
name: edenproxy
spec:
replicas: 2
selector:
matchLabels:
app: edenproxy
template:
metadata:
labels:
app: edenproxy
spec:
imagePullSecrets:
- name: regcred
containers:
- image: ${DOCKER_REGISTRY}/${IMAGE_NAME}:${VERSION}
name: edenproxy
ports:
- containerPort: 80
name: http
resources:
requests:
cpu: 150m
limits:
cpu: "1"
env:
- name: APP_NAME
value: edenproxy
dnsConfig:
nameservers:
- 10.43.0.10
searches:
- edenproxy.svc.cluster.local
- svc.cluster.local
- cluster.local
dnsPolicy: None
File renamed without changes.
11 changes: 11 additions & 0 deletions k8s-pdn/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: edenproxy
spec:
selector:
app: edenproxy
ports:
- port: 3000
targetPort: 3000
protocol: TCP
32 changes: 32 additions & 0 deletions k8s-pdn/voter.cronjob.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: voter-cronjob
spec:
schedule: "0 0 * * *"
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
spec:
containers:
- name: voter
image: ${DOCKER_REGISTRY}/${IMAGE_NAME_VOTER}:${VERSION}
imagePullPolicy: IfNotPresent
command: [ "node" ]
args: [ "/app/src/index.js" ]
env:
- name: EOS_API_ENDPOINT
value: "${EOS_API_ENDPOINT}"
- name: EOS_API_CHAIN_ID
value: "${EOS_API_CHAIN_ID}"
- name: EOS_VOTER_ACCOUNT
value: "${EOS_VOTER_ACCOUNT}"
- name: EOS_VOTER_PERMISSION
value: "${EOS_VOTER_PERMISSION}"
- name: EOS_VOTER_PRIVATE_KEY
value: "${EOS_VOTER_PRIVATE_KEY}"
- name: EOS_PROXY_ACCOUNT
value: "${EOS_PROXY_ACCOUNT}"
restartPolicy: Never
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ push-image:
@docker push $(DOCKER_REGISTRY)/$(IMAGE_NAME):$(LATEST_TAG)

build-kubernetes: ##@devops Generate proper k8s files based on the templates
build-kubernetes: ./k8s
build-kubernetes: ./k8s-$(ENVIRONMENT)
@echo "Build kubernetes files..."
@rm -Rf $(K8S_BUILD_DIR) && mkdir -p $(K8S_BUILD_DIR)
@for file in $(K8S_FILES); do \
Expand Down
4 changes: 1 addition & 3 deletions utils/meta.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

VERSION ?= $(shell git ls-files -s nginx.conf k8s public src package.json yarn.lock Dockerfile | git hash-object --stdin)

IMAGE_NAME=eden-proxy-webapp
IMAGE_NAME_VOTER=proxy-voter
IMAGE_ID=$(shell docker images --format '{{.ID}}' --filter reference='docker.pkg.github.com/edenia/eden-smart-proxy*latest')
DOCKER_REGISTRY=ghcr.io/edenia

MAKE_ENV += DOCKER_REGISTRY VERSION IMAGE_NAME IMAGE_NAME_VOTER
MAKE_ENV += DOCKER_REGISTRY VERSION

SHELL_EXPORT := $(foreach v,$(MAKE_ENV),$(v)='$($(v))')
K8S_BUILD_DIR ?= ./build_k8s
Expand Down