-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Łukasz Kosiak <[email protected]>
- Loading branch information
1 parent
487523b
commit 4069e1d
Showing
12 changed files
with
316 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Emacs backup files. | ||
*~ | ||
.\#* | ||
\#* | ||
|
||
# Secrets files. | ||
**/config/**/*.secret.yaml | ||
**/target | ||
|
||
**/secrets.cache.yaml | ||
|
||
# NextJS ignores | ||
|
||
## dependencies | ||
**/node_modules | ||
**/.pnp | ||
**/.pnp.js | ||
|
||
## testing | ||
**/coverage | ||
|
||
## next.js | ||
**/.next/ | ||
**/.env*.local | ||
|
||
## production | ||
**/build | ||
|
||
## misc | ||
**/.DS_Store | ||
**/*.pem | ||
|
||
## debug | ||
**/npm-debug.log* | ||
**/yarn-debug.log* | ||
**/yarn-error.log* | ||
**/.pnpm-debug.log* | ||
|
||
## Github | ||
|
||
.github | ||
|
||
## z | ||
|
||
renders | ||
zenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
name: "CICD zq2-staking" | ||
|
||
on: | ||
# Test run before merging | ||
pull_request: | ||
branches: | ||
- main | ||
# On merged | ||
push: | ||
branches: | ||
- main | ||
# On released | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build-docker-buildx-stg: | ||
permissions: | ||
id-token: write | ||
contents: write | ||
runs-on: ubuntu-22.04 | ||
if: github.actor != 'dependabot[bot]' && (github.event_name == 'pull_request' || github.event_name == 'push') && github.ref_name == 'main' | ||
name: "Deploy image STG" | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
application: | ||
[ | ||
zq2-staking/zq2-staking-frontend, | ||
] | ||
include: | ||
- application: zq2-staking/zq2-staking-frontend | ||
image_name: zq2-staking-frontend | ||
file: images/frontend/Dockerfile | ||
context: . | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: "true" | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
fetch-depth: 0 | ||
|
||
- name: Docker build and push | ||
uses: Zilliqa/gh-actions-workflows/actions/ci-dockerized-app-build-push@v2 | ||
with: | ||
file: ${{ matrix.file }} | ||
context: ${{ matrix.context }} | ||
push: ${{ github.ref_name == github.event.repository.default_branch }} | ||
tag: asia-docker.pkg.dev/prj-d-devops-services-4dgwlsse/zilliqa-private/${{ matrix.image_name }} | ||
tag-length: 8 | ||
tag-latest: false | ||
registry: asia-docker.pkg.dev | ||
workload-identity-provider: "${{ secrets.GCP_PRD_GITHUB_WIF }}" | ||
service-account: "${{ secrets.GCP_STG_GITHUB_SA_DOCKER_REGISTRY }}" | ||
cache-key: asia-docker.pkg.dev/prj-d-devops-services-4dgwlsse/zilliqa-private/${{ matrix.image_name }}-cache | ||
build-args: | | ||
DEPLOY_ENV=stg | ||
build-docker-buildx-prd: | ||
permissions: | ||
id-token: write | ||
contents: write | ||
runs-on: ubuntu-22.04 | ||
if: github.event_name == 'release' | ||
name: "Deploy image PRD" | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
application: | ||
[ | ||
zq2-staking/zq2-staking-frontend, | ||
] | ||
include: | ||
- application: zq2-staking/zq2-staking-frontend | ||
image_name: zq2-staking-frontend | ||
file: images/frontend/Dockerfile | ||
context: . | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: "true" | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
fetch-depth: 0 | ||
|
||
- name: Docker build and push | ||
uses: Zilliqa/gh-actions-workflows/actions/ci-dockerized-app-build-push@v2 | ||
with: | ||
file: ${{ matrix.file }} | ||
context: ${{ matrix.context }} | ||
push: true | ||
tag: asia-docker.pkg.dev/prj-p-devops-services-tvwmrf63/zilliqa-private/${{ matrix.image_name }}:${{ github.ref_name }} | ||
tag-latest: true | ||
registry: asia-docker.pkg.dev | ||
workload-identity-provider: "${{ secrets.GCP_PRD_GITHUB_WIF }}" | ||
service-account: "${{ secrets.GCP_PRD_GITHUB_SA_DOCKER_REGISTRY }}" | ||
cache-key: asia-docker.pkg.dev/prj-p-devops-services-tvwmrf63/zilliqa-private/${{ matrix.image_name }}-cache | ||
build-args: | | ||
DEPLOY_ENV=prd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
zq2_staking: | ||
wallet_connect_api_key: | ||
_op: "op://prj-d-staging/zq2-staking/WALLET_CONNECT_API_KEY" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
FROM node:20 AS builder | ||
|
||
WORKDIR /build | ||
COPY . . | ||
|
||
RUN npm install | ||
RUN npm run build | ||
|
||
FROM node:20-alpine AS runner | ||
|
||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. | ||
RUN apk add --no-cache libc6-compat | ||
|
||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
# Next.js collects completely anonymous telemetry data about general usage. | ||
# Learn more here: https://nextjs.org/telemetry | ||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
COPY --from=builder --chown=nextjs:nodejs /build/.next/standalone . | ||
COPY --from=builder --chown=nextjs:nodejs /build/.next/static ./.next/static | ||
COPY --from=builder --chown=nextjs:nodejs /build/.next/server ./.next/server | ||
COPY --from=builder /build/public ./public | ||
|
||
COPY --from=builder --chown=nextjs:nodejs /build/etc ./etc | ||
|
||
RUN chown nextjs:nodejs ./.next | ||
|
||
USER nextjs | ||
|
||
EXPOSE 3000 | ||
|
||
ENV PORT 3000 | ||
ENV HOSTNAME "0.0.0.0" | ||
|
||
CMD ["node", "./server.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.PHONY: all | ||
all: image/build-and-push | ||
|
||
.ONESHELL: | ||
SHELL := /bin/bash | ||
.SHELLFLAGS = -ec | ||
|
||
ENVIRONMENT ?= dev | ||
VALID_ENVIRONMENTS := dev stg prd | ||
IMAGE_TAG ?= localhost:5001/zq2-staking-frontend:latest | ||
|
||
# Check if the ENVIRONMENT variable is in the list of valid environments | ||
ifeq ($(filter $(ENVIRONMENT),$(VALID_ENVIRONMENTS)),) | ||
$(error Invalid value for ENVIRONMENT. Valid values are dev, stg, or prd.) | ||
endif | ||
|
||
## Build and push the Docker image | ||
image/build-and-push: | ||
cd ../../ && docker build -f images/frontend/Dockerfile -t "${IMAGE_TAG}" . | ||
docker push "${IMAGE_TAG}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
project_id: prj-d-staging-6zj2hygf | ||
bastion_instance_name: vm-d-staging-bastion-ase1 | ||
bastion_instance_zone: asia-southeast1-a | ||
region: asia-southeast1 | ||
|
||
k8s_clusters: | ||
staging: | ||
project_id: "prj-d-staging-6zj2hygf" | ||
name: gke-d-staging-01-ase1 | ||
|
||
registry: asia-docker.pkg.dev/prj-d-devops-services-4dgwlsse/zilliqa-private | ||
|
||
dbs_to_instances: [] | ||
|
||
apps_to_clusters: | ||
- name_re: main/zq2-staking/zq2-staking-frontend | ||
cluster: staging | ||
dns_name: zq2-staking.zilstg.dev | ||
healthcheck: | ||
request_path: /health | ||
image_name: zq2-staking-frontend | ||
namespace: zq2-staking-stg | ||
pipeline: | ||
dockerfile_path: images/frontend/Dockerfile | ||
context: . | ||
replicas: 1 | ||
env_vars: | ||
- name: ZQ2_STAKING_CHAIN_ID | ||
value: 33469 | ||
pod_limits: | ||
cpu: 200m | ||
memory: 200Mi | ||
pod_requests: | ||
cpu: 100m | ||
memory: 100Mi | ||
|
||
secrets: | ||
zq2_staking: | ||
wallet_connect_api_key: | ||
_op: "op://prj-d-staging/zq2-staking/WALLET_CONNECT_API_KEY" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const cli = require("next/dist/cli/next-dev"); | ||
|
||
const overridePort = process.env.Z_LISTEN_PORT; | ||
|
||
if (process.argv.length > 2 && process.argv[2] === "set_env") { | ||
process.env.Z_CONFIG = "../etc/testnet"; | ||
} | ||
|
||
if (overridePort === undefined) { | ||
console.log("running on default nextjs port"); | ||
cli.nextDev({ | ||
_: [null], | ||
}); | ||
} else { | ||
console.log("overridePort", overridePort); | ||
cli.nextDev({ | ||
_: [null], | ||
"port": Number.parseInt(overridePort), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
if [[ "$SHELL" == *"zsh"* ]] ; then | ||
echo "Running on $SHELL ..." | ||
BASEDIR=`realpath $(dirname "$0")`/.. | ||
else | ||
BASEDIR=`realpath $(dirname "$BASH_SOURCE")`/.. | ||
fi | ||
|
||
export Z_ENV=${BASEDIR}/zenv | ||
export Z_CONFIG=${BASEDIR}/etc/testnet | ||
|
||
source ${BASEDIR}/../devops/setenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
backend: kind | ||
kind: zq2staking | ||
clusters: | ||
main: | ||
aws_name: dev | ||
aws_region: eu-west-2 | ||
container_registry: foo | ||
# Manifests are add-ons, deployed to your cluster to add functionality. | ||
manifests: {} | ||
# applications: these will be pulled from your git repository. | ||
apps: | ||
zq2-staking: | ||
path: z/zq2-staking | ||
track: development | ||
type: kustomize | ||
dev: | ||
- path: . | ||
name: zq2-staking-frontend | ||
command: npm run local_z | ||
is_entrypoint: true | ||
env_vars: | ||
- name: ZQ2_STAKING_CHAIN_ID | ||
value: 33469 | ||
secrets: | ||
- name: ZQ2_STAKING_WALLET_CONNECT_API_KEY | ||
from: zq2_staking.wallet_connect_api_key |