Skip to content

Commit

Permalink
✨ TezosLink milestone 2
Browse files Browse the repository at this point in the history
Co-authored-by: ismail bennis <ismailbennis@MacBook-Pro-de-ismail.local>
Co-authored-by: Massi <massi.hamidouche@smart-chain.fr>
Co-authored-by: Elise <elise.hautefaye@smart-chain.fr>
Co-authored-by: KevinTanDev <kevintan.dev@gmail.com>
Co-authored-by: gisele-igore <gisele.dekpe@smart-chain.fr>
Co-authored-by: Pidanou Eang <104195814+pida123@users.noreply.github.com>
Co-authored-by: pida123 <pidanou.eang@smart-chain.fr>
Co-authored-by: Loïs Mansot <26844641+devfull@users.noreply.github.com>
  • Loading branch information
9 people committed Apr 27, 2023
1 parent b8aa32b commit a1e8c5e
Show file tree
Hide file tree
Showing 127 changed files with 15,979 additions and 2 deletions.
118 changes: 118 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
version: 2.1

orbs:
kubernetes: circleci/kubernetes@1.0.0
helm: circleci/helm@2.0.1


jobs:
build-push-docker-image:
docker:
- image: cimg/base:stable
environment:
TAG: << pipeline.git.tag >>
steps:
- checkout
- setup_remote_docker:
version: 20.10.12
docker_layer_caching: true
- run: docker login rg.fr-par.scw.cloud/tezoslink -u nologin -p $SCW_SECRET_KEY
- run: docker build --tag rg.fr-par.scw.cloud/tezoslink/p1-api:$TAG -f Dockerfiles/Dockerfile.api .
- run: docker push rg.fr-par.scw.cloud/tezoslink/p1-api:$TAG
- run: docker login rg.fr-par.scw.cloud/tezoslink -u nologin -p $SCW_SECRET_KEY
- run: docker build --tag rg.fr-par.scw.cloud/tezoslink/p1-frontend:$TAG -f Dockerfiles/Dockerfile.front .
- run: docker push rg.fr-par.scw.cloud/tezoslink/p1-frontend:$TAG
- run: docker login rg.fr-par.scw.cloud/tezoslink -u nologin -p $SCW_SECRET_KEY
- run: docker build --tag rg.fr-par.scw.cloud/tezoslink/p1-proxy:$TAG -f Dockerfiles/Dockerfile.proxy .
- run: docker push rg.fr-par.scw.cloud/tezoslink/p1-proxy:$TAG

deploy-docker-image:
docker:
- image: cimg/base:stable
environment:
TAG: << pipeline.git.tag >>
steps:
- checkout
- kubernetes/install-kubeconfig:
kubeconfig: KUBECONFIG_DATA
- helm/install-helm-client
- run:
name: Deploy
command: >
helm upgrade
tezos-link helm-charts-p2 -i -f helm-charts-p2/values.yaml
-n tezos-link
--create-namespace
--set api.image.tag=$TAG
--set api.image.repository='rg.fr-par.scw.cloud/tezoslink/p1-api'
--set front.image.tag=$TAG
--set front.image.repository='rg.fr-par.scw.cloud/tezoslink/p1-frontend'
--set proxy.image.tag=$TAG
--set proxy.image.repository='rg.fr-par.scw.cloud/tezoslink/p1-proxy'
package-helm-chart:
docker:
- image: cimg/base:stable
steps:
- checkout
- helm/install-helm-client
- run:
name: Helm dependency build
command: helm dependency build charts
- run:
name: Helm lint
command: helm lint charts
- run:
name: Install Chart Releaser
command: |
cd /tmp
curl -sSL https://github.com/helm/chart-releaser/releases/download/v1.5.0/chart-releaser_1.5.0_linux_amd64.tar.gz --output cr.tar.gz
tar xzf cr.tar.gz
mv cr ~/bin/cr
- add_ssh_keys:
fingerprints:
- "0c:70:41:4f:0f:36:96:34:d5:5c:71:fb:a6:94:91:90"
- run:
name: Deploy Chart
command: |
git config user.email "devops@smart-chain.fr"
git config user.name "CircleCI Job"
helm package charts --destination .deploy
cr upload -o smart-chain-fr -r tezoslink -p .deploy
echo FINISHUPLOAD
git checkout gh-pages
cr index -i ./index.yaml -p .deploy -o smart-chain-fr -r tezoslink -c https://smart-chain-fr.github.io/tezosLink/
git add index.yaml
git commit -m "Automatic commit from CircleCI [skip ci]"
git push origin gh-pages
workflows:
version: 2
build-and-register:
jobs:
- build-push-docker-image:
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- deploy-docker-image:
requires:
- build-push-docker-image
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/

deploy-helm-chart:
jobs:
- package-helm-chart:
filters:
branches:
only:
- main

26 changes: 26 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
PROMETHEUS_URL="http://localhost:9090"
PROMETHEUS_NAMESPACE_TEZOSLINK="default"
PROMETHEUS_NAMESPACE_TEZOS_K8S_MAINNET="poc-tzk8s"
PROMETHEUS_NAMESPACE_TEZOS_K8S_TESTNET="poc-tzk8s-limanet"

DATABASE_HOSTNAME="localhost"
DATABASE_PORT="5432"
DATABASE_USER="postgres"
DATABASE_PASSWORD="0000"
DATABASE_NAME="tezoslink"

API_LABEL="TezosLink API"
API_PORT=3001
API_ROOT_URL="/api"

RPC_GATEWAY_LABEL="TezosLink RPC Gateway"
RPC_GATEWAY_PORT=3002
RPC_GATEWAY_ROOT_URL="/rpc"

ARCHIVE_NODES_URL="https://api.tez.ie/rpc/mainnet"
ARCHIVE_NODES_PORT=443
ROLLING_NODES_URL="https://api.tez.ie/rpc/mainnet"
ROLLING_NODES_PORT=443
TEZOS_NETWORK="TESTNET"

DEV_PRISMA_STUDIO_DB_URL=postgres://postgres:0000@localhost:5432/tezoslink
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

dist
.next

# dependencies
/node_modules

# envs
.env

# misc
.DS_Store
*.pem

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

# local env files
.env*.local

# typescript
*.tsbuildinfo

# jest

src/coverage

*.values.yaml
35 changes: 35 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": false,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"terminal.integrated.env.linux": {
"PATH": "${env:HOME}/elrondsdk/vendor-rust/bin:${env:HOME}/elrondsdk/erdpy-venv/bin:${env:HOME}/elrondsdk/vmtools:${env:HOME}/elrondsdk/nodejs/latest/bin:${env:PATH}",
"VIRTUAL_ENV": "${env:HOME}/elrondsdk/erdpy-venv",
"RUSTUP_HOME": "${env:HOME}/elrondsdk/vendor-rust",
"CARGO_HOME": "${env:HOME}/elrondsdk/vendor-rust"
},
"terminal.integrated.env.osx": {
"PATH": "${env:HOME}/elrondsdk/vendor-rust/bin:${env:HOME}/elrondsdk/erdpy-venv/bin:${env:HOME}/elrondsdk/vmtools:${env:HOME}/elrondsdk/nodejs/latest/bin:${env:PATH}",
"VIRTUAL_ENV": "${env:HOME}/elrondsdk/erdpy-venv",
"RUSTUP_HOME": "${env:HOME}/elrondsdk/vendor-rust",
"CARGO_HOME": "${env:HOME}/elrondsdk/vendor-rust"
},
"terminal.integrated.environmentChangesIndicator": "on",
"terminal.integrated.inheritEnv": true,
"workbench.dialogs.customEnabled": true,
"rust-client.rustupPath": "${env:HOME}/elrondsdk/vendor-rust/bin/rustup",
"rust-client.rlsPath": "${env:HOME}/elrondsdk/vendor-rust/bin/rls",
"rust-client.disableRustup": true,
"rust-client.autoStartRls": false
}
40 changes: 40 additions & 0 deletions Dockerfiles/Dockerfile.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Install dependencies only when needed
FROM node:19-alpine AS deps

WORKDIR tezosLink

COPY package.json ./
COPY src/common/databases/schema.prisma ./src/common/databases/schema.prisma
RUN npx prisma generate

RUN npm install --frozen-lockfile

# Rebuild the source code only when needed
FROM node:19-alpine AS builder

WORKDIR tezosLink

COPY . .
COPY --from=deps tezosLink/node_modules ./node_modules
RUN npx prisma generate
RUN npm run build

# Production image, copy all the files and run next
FROM node:19-alpine AS production

WORKDIR tezosLink

RUN adduser -D tezoslinkuser --uid 10000 && chown -R tezoslinkuser .

RUN mkdir src && mkdir src/common && mkdir src/common/databases

COPY --from=builder --chown=tezoslinkuser tezosLink/node_modules ./node_modules
COPY --from=builder --chown=tezoslinkuser tezosLink/dist/api ./dist/api
COPY --from=builder --chown=tezoslinkuser tezosLink/dist/entries ./dist/entries
COPY --from=builder --chown=tezoslinkuser tezosLink/dist/common ./dist/common
COPY --from=builder --chown=tezoslinkuser tezosLink/src/common/databases/ ./src/common/databases/
COPY --from=builder --chown=tezoslinkuser tezosLink/package.json ./package.json
USER tezoslinkuser

CMD ["npm", "run", "api:start"]
EXPOSE 3001
38 changes: 38 additions & 0 deletions Dockerfiles/Dockerfile.cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Install dependencies only when needed
FROM node:19-alpine AS deps

WORKDIR tezosLink

COPY package.json ./
COPY src/common/databases/schema.prisma ./src/common/databases/schema.prisma
RUN npx prisma generate

RUN npm install --frozen-lockfile

# Rebuild the source code only when needed
FROM node:19-alpine AS builder

WORKDIR tezosLink

COPY . .
COPY --from=deps tezosLink/node_modules ./node_modules
RUN npx prisma generate
RUN npm run build

# Production image, copy all the files and run next
FROM node:19-alpine AS production

WORKDIR tezosLink

RUN adduser -D tezoslinkuser --uid 10000 && chown -R tezoslinkuser .

COPY --from=builder --chown=tezoslinkuser tezosLink/node_modules ./node_modules
COPY --from=builder --chown=tezoslinkuser tezosLink/dist/api ./dist/api
COPY --from=builder --chown=tezoslinkuser tezosLink/dist/entries ./dist/entries
COPY --from=builder --chown=tezoslinkuser tezosLink/dist/common ./dist/common
COPY --from=builder --chown=tezoslinkuser tezosLink/package.json ./package.json

USER tezoslinkuser

CMD ["npm", "run", "cron:start"]
EXPOSE 3001
10 changes: 10 additions & 0 deletions Dockerfiles/Dockerfile.full
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Install dependencies only when needed
FROM node:19-alpine AS deps

WORKDIR tezosLink

COPY . .
RUN npm i
RUN npm run build
CMD ["npm", "run", "web:start"]
EXPOSE 3000
40 changes: 40 additions & 0 deletions Dockerfiles/Dockerfile.proxy
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Install dependencies only when needed
FROM node:19-alpine AS deps

WORKDIR tezosLink

COPY package.json ./

RUN npm install --frozen-lockfile

# Rebuild the source code only when needed
FROM node:19-alpine AS builder

WORKDIR tezosLink

COPY . .
COPY --from=deps tezosLink/node_modules ./node_modules
RUN npx prisma generate
RUN npm run build

# Production image, copy all the files and run next
FROM node:19-alpine AS production

WORKDIR tezosLink

RUN adduser -D tezoslinkuser --uid 10000 && chown -R tezoslinkuser .

RUN mkdir src && mkdir src/common && mkdir src/common/databases

COPY --from=builder --chown=tezoslinkuser tezosLink/node_modules ./node_modules
COPY --from=builder --chown=tezoslinkuser tezosLink/dist/rpc-gateway ./dist/rpc-gateway
COPY --from=builder --chown=tezoslinkuser tezosLink/dist/entries ./dist/entries
COPY --from=builder --chown=tezoslinkuser tezosLink/package.json ./package.json
COPY --from=builder --chown=tezoslinkuser tezosLink/dist/common ./dist/common
COPY --from=builder --chown=tezoslinkuser tezosLink/src/common/databases/ ./src/common/databases/
COPY --from=builder --chown=tezoslinkuser tezosLink/dist/api ./dist/api

USER tezoslinkuser

CMD ["npm", "run", "rpc-gateway:start"]
EXPOSE 3002
Loading

0 comments on commit a1e8c5e

Please sign in to comment.