diff --git a/.github/workflows/kread-emerynet-cicd.yml b/.github/workflows/kread-emerynet-cicd.yml new file mode 100644 index 000000000..787321f9e --- /dev/null +++ b/.github/workflows/kread-emerynet-cicd.yml @@ -0,0 +1,58 @@ +name: CI/CD Emerynet + +on: + pull_request: + branches: + - develop + types: + - closed + +jobs: + build_and_deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Install Skaffold + run: | + curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 + sudo install skaffold /usr/local/bin/ + shell: bash + + - name: Authenticate with Google Cloud + uses: google-github-actions/setup-gcloud@v0 + with: + service_account_key: ${{ secrets.GCP_AUTH_KEY }} + project_id: ${{ secrets.PROJECT_ID }} + export_default_credentials: true + + - name: Activate Service Account + run: | + gcloud auth activate-service-account ${{ secrets.GCP_SA }} --key-file=$GOOGLE_APPLICATION_CREDENTIALS + gcloud components install gke-gcloud-auth-plugin + + - name: Login to GCR + uses: docker/login-action@v3 + with: + registry: eu.gcr.io + username: _json_key + password: ${{ secrets.GCP_AUTH_KEY }} + + - name: Login to Kubernetes + uses: azure/k8s-set-context@v1 + with: + kubeconfig: ${{ secrets.KUBECONFIG }} + cluster-context: ${{ secrets.CLUSTER_CONTEXT }} + namespace: ${{ secrets.K8S_NAMESPACE_EMERYNET }} + + - name: Build and push Docker images + run: | + cd frontend + export $(grep -v '^#' .env.emerynet | xargs) + envsubst < ../deployment/emerynet/workloads/config/ui-config.template.yaml > ../deployment/emerynet/workloads/config/ui-config.yaml + envsubst < skaffold.emerynet.template.yaml > skaffold.emerynet.yaml + skaffold run --filename skaffold.emerynet.yaml + shell: bash + diff --git a/.github/workflows/kread-mainnet-cicd.yml b/.github/workflows/kread-mainnet-cicd.yml new file mode 100644 index 000000000..267b959d6 --- /dev/null +++ b/.github/workflows/kread-mainnet-cicd.yml @@ -0,0 +1,58 @@ +name: CI/CD Mainnet + +on: + pull_request: + branches: + - main + types: + - closed + +jobs: + build_and_deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Install Skaffold + run: | + curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 + sudo install skaffold /usr/local/bin/ + shell: bash + + - name: Authenticate with Google Cloud + uses: google-github-actions/setup-gcloud@v0 + with: + service_account_key: ${{ secrets.GCP_AUTH_KEY }} + project_id: ${{ secrets.PROJECT_ID }} + export_default_credentials: true + + - name: Activate Service Account + run: | + gcloud auth activate-service-account ${{ secrets.GCP_SA }} --key-file=$GOOGLE_APPLICATION_CREDENTIALS + gcloud components install gke-gcloud-auth-plugin + + - name: Login to GCR + uses: docker/login-action@v3 + with: + registry: eu.gcr.io + username: _json_key + password: ${{ secrets.GCP_AUTH_KEY }} + + - name: Login to Kubernetes + uses: azure/k8s-set-context@v1 + with: + kubeconfig: ${{ secrets.KUBECONFIG }} + cluster-context: ${{ secrets.CLUSTER_CONTEXT }} + namespace: ${{ secrets.K8S_NAMESPACE_MAINNET }} + + - name: Build and push Docker images + run: | + cd frontend + export $(grep -v '^#' .env.mainnet | xargs) + envsubst < ../deployment/mainnet/workloads/config/ui-config.template.yaml > ../deployment/mainnet/workloads/config/ui-config.yaml + envsubst < skaffold.mainnet.template.yaml > skaffold.mainnet.yaml + skaffold run --filename skaffold.mainnet.yaml + shell: bash + diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 000000000..83abb500f --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,2 @@ +* @WietzeSlagman +* @carlos-kryha diff --git a/azure-pipelines-prod.yml b/azure-pipelines-prod.yml deleted file mode 100644 index 48c1a6720..000000000 --- a/azure-pipelines-prod.yml +++ /dev/null @@ -1,38 +0,0 @@ -trigger: - - production - -pool: - vmImage: "ubuntu-latest" - -stages: - - stage: build_and_deploy - displayName: Build and Deploy - dependsOn: [] - condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) - jobs: - - job: build_and_deploy - displayName: Build Docker images and deploy through Kubernetes - steps: - - script: curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && sudo install skaffold /usr/local/bin/ - displayName: Install Skaffold - - task: DownloadSecureFile@1 - name: authkey - displayName: "Download Service Account Key" - inputs: - secureFile: web3-agoric.json - retryCount: "2" - - script: gcloud auth activate-service-account web3-agoric-0@web3-335312.iam.gserviceaccount.com --key-file=$(authkey.secureFilePath) - displayName: Activate Service Account - - task: Kubernetes@1 - inputs: - connectionType: "Kubernetes Service Connection" - kubernetesServiceEndpoint: "gke-service-connection" - namespace: "character-builder-prod" - command: "login" - - script: | - cd frontend - export $(grep -v '^#' .env.production | xargs) - envsubst < ../deployment/production/workloads/config/ui-config.template.yaml > ../deployment/production/workloads/config/ui-config.yaml - envsubst < skaffold.production.template.yaml > skaffold.production.yaml - skaffold run --filename skaffold.production.yaml - displayName: Build and push docker images diff --git a/azure-pipelines.old.yml b/azure-pipelines.old.yml deleted file mode 100644 index 0f0aa66fc..000000000 --- a/azure-pipelines.old.yml +++ /dev/null @@ -1,58 +0,0 @@ -trigger: - - develop - -pool: - vmImage: "ubuntu-latest" - -stages: - - stage: build - displayName: Build - dependsOn: [] - condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) - jobs: - - job: build - displayName: Build Docker images - steps: - - script: curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && sudo install skaffold /usr/local/bin/ - displayName: Install Skaffold - - script: echo "##vso[task.setvariable variable=BUILDSTATE;isOutput=true]build-$(git rev-list -1 HEAD --abbrev-commit).json" - name: printvar - displayName: Write state variable - - task: DownloadSecureFile@1 - name: authkey - displayName: "Download Service Account Key" - inputs: - secureFile: web3-agoric.json - retryCount: "2" - - script: gcloud auth activate-service-account web3-agoric-0@web3-335312.iam.gserviceaccount.com --key-file=$(authkey.secureFilePath) - displayName: Activate Service Account - - script: cd frontend && skaffold build --filename skaffold.staging.yaml --file-output "../$(printvar.BUILDSTATE)" - displayName: Build and push docker images - - publish: $(printvar.BUILDSTATE) - artifact: BuildArtifacts - displayName: Publish build artifacts - - - stage: deploy - displayName: Deploy - dependsOn: [build] - variables: - BUILDSTATE: $[ stageDependencies.build.build.outputs['printvar.BUILDSTATE'] ] - jobs: - - job: deploy - displayName: Deploy - steps: - - task: Kubernetes@1 - inputs: - connectionType: "Kubernetes Service Connection" - kubernetesServiceEndpoint: "gke-service-connection" - namespace: "character-builder-staging" - command: "login" - - script: curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && sudo install skaffold /usr/local/bin/ - displayName: Install Skaffold - - task: DownloadPipelineArtifact@2 - displayName: Download build artifacts - inputs: - artifactName: BuildArtifacts - targetPath: $(System.DefaultWorkingDirectory) - - script: cd frontend && skaffold deploy --filename skaffold.staging.yaml --build-artifacts "../$(BUILDSTATE)" - displayName: Deploy build artifacts diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 4c7cbbeec..000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,38 +0,0 @@ -trigger: - - develop - -pool: - vmImage: "ubuntu-latest" - -stages: - - stage: build_and_deploy - displayName: Build and Deploy - dependsOn: [] - condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) - jobs: - - job: build_and_deploy - displayName: Build Docker images and deploy through Kubernetes - steps: - - script: curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && sudo install skaffold /usr/local/bin/ - displayName: Install Skaffold - - task: DownloadSecureFile@1 - name: authkey - displayName: "Download Service Account Key" - inputs: - secureFile: web3-agoric.json - retryCount: "2" - - script: gcloud auth activate-service-account web3-agoric-0@web3-335312.iam.gserviceaccount.com --key-file=$(authkey.secureFilePath) - displayName: Activate Service Account - - task: Kubernetes@1 - inputs: - connectionType: "Kubernetes Service Connection" - kubernetesServiceEndpoint: "gke-service-connection" - namespace: "character-builder-staging" - command: "login" - - script: | - cd frontend - export $(grep -v '^#' .env.staging | xargs) - envsubst < ../deployment/staging/workloads/config/ui-config.template.yaml > ../deployment/staging/workloads/config/ui-config.yaml - envsubst < skaffold.staging.template.yaml > skaffold.staging.yaml - skaffold run --filename skaffold.staging.yaml - displayName: Build and push docker images diff --git a/deployment/emerynet/workloads/config/ui-config.template.yaml b/deployment/emerynet/workloads/config/ui-config.template.yaml new file mode 100644 index 000000000..8dc80fbd5 --- /dev/null +++ b/deployment/emerynet/workloads/config/ui-config.template.yaml @@ -0,0 +1,13 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ui +spec: + selector: + matchLabels: + app: ui + template: + spec: + containers: + - name: ui + image: "eu.gcr.io/web3-335312/kread/frontend-staging/frontend:latest" \ No newline at end of file diff --git a/deployment/emerynet/workloads/ingresses/ui.yaml b/deployment/emerynet/workloads/ingresses/ui.yaml new file mode 100644 index 000000000..06f8b9540 --- /dev/null +++ b/deployment/emerynet/workloads/ingresses/ui.yaml @@ -0,0 +1,23 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: ui-devnet + annotations: + kubernetes.io/ingress.class: "nginx" + cert-manager.io/cluster-issuer: "letsencrypt-staging" + nginx.ingress.kubernetes.io/rewrite-target: /$1 + nginx.ingress.kubernetes.io/proxy-body-size: 200m +spec: + ports: + - name: 80-tcp + port: 80 + protocol: TCP + targetPort: 80 + - name: 443-tcp + port: 443 + protocol: TCP + targetPort: 443 + selector: + app: ui + sessionAffinity: None + type: ClusterIP diff --git a/deployment/emerynet/workloads/kustomization.yaml b/deployment/emerynet/workloads/kustomization.yaml new file mode 100644 index 000000000..3c20e628a --- /dev/null +++ b/deployment/emerynet/workloads/kustomization.yaml @@ -0,0 +1,7 @@ +bases: + - ../../base +resources: + - namespace/namespace.yaml +patchesStrategicMerge: + - config/ui-config.yaml +namespace: agoric-makefile-automation diff --git a/deployment/emerynet/workloads/namespace/namespace.yaml b/deployment/emerynet/workloads/namespace/namespace.yaml new file mode 100644 index 000000000..ac5c02c29 --- /dev/null +++ b/deployment/emerynet/workloads/namespace/namespace.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: agoric-makefile-automation + + diff --git a/deployment/production/workloads/config/ui-config.template.yaml b/deployment/production/workloads/config/ui-config.template.yaml index d0e03dc07..3658c36aa 100644 --- a/deployment/production/workloads/config/ui-config.template.yaml +++ b/deployment/production/workloads/config/ui-config.template.yaml @@ -10,4 +10,4 @@ spec: spec: containers: - name: ui - image: "$DOCKER_REPO:latest" + image: "eu.gcr.io/web3-335312/kread/frontend-production/frontend:latest" diff --git a/frontend/Dockerfile.ui b/frontend/Dockerfile.ui index dcc6f73c5..72c8a655e 100644 --- a/frontend/Dockerfile.ui +++ b/frontend/Dockerfile.ui @@ -1,4 +1,4 @@ -FROM node:16-alpine as build +FROM node:18-alpine as build RUN apk --no-cache add --update git python3 make g++ @@ -6,10 +6,22 @@ WORKDIR /usr/main/ RUN yarn set version 2 --only-if-needed -ENV GENERATE_SOURCEMAP false +ENV GENERATE_SOURCEMAP true -ARG VITE_DAPP_CONSTANTS_JSON -ENV VITE_DAPP_CONSTANTS_JSON $VITE_DAPP_CONSTANTS_JSON +ARG VITE_RPC +ENV VITE_RPC $VITE_RPC + +ARG VITE_BRIDE_HREF +ENV VITE_BRIDE_HREF $VITE_BRIDE_HREF + +ARG VITE_BASE_URL +ENV VITE_BASE_URL $VITE_BASE_URL + +ARG PINATA_GATEWAY +ENV PINATA_GATEWAY $PINATA_GATEWAY + +ARG VITE_NETWORK_CONFIG +ENV VITE_NETWORK_CONFIG $VITE_NETWORK_CONFIG COPY .yarnrc.yml ./.yarnrc.yml COPY yarn.lock ./yarn.lock @@ -18,9 +30,14 @@ COPY .yarn/ ./.yarn/ COPY .eslintrc.json ./.eslintrc.json COPY .eslintignore ./.eslintignore +COPY index.html ./index.html + COPY package.json ./package.json + COPY tsconfig.json ./tsconfig.json -COPY config-overrides.js ./config-overrides.js +COPY tsconfig.node.json ./tsconfig.node.json + +COPY vite.config.ts ./vite.config.ts COPY public/ ./public/ COPY src/ ./src/ @@ -33,7 +50,7 @@ FROM nginx:1.21-alpine as run RUN sed -i '/location \//a try_files $uri $uri/ /index.html;' /etc/nginx/conf.d/default.conf -COPY --from=build /usr/main/build/ /usr/share/nginx/html/ +COPY --from=build /usr/main/dist/ /usr/share/nginx/html/ EXPOSE 80 diff --git a/frontend/skaffold.emerynet.template.yaml b/frontend/skaffold.emerynet.template.yaml new file mode 100644 index 000000000..b723592fa --- /dev/null +++ b/frontend/skaffold.emerynet.template.yaml @@ -0,0 +1,25 @@ +apiVersion: skaffold/v2beta27 +kind: Config +metadata: + name: character-builder-ui +build: + tagPolicy: + sha256: {} + local: + concurrency: 0 + push: true + artifacts: + - image: eu.gcr.io/web3-335312/kread/frontend-staging/frontend + docker: + dockerfile: Dockerfile.ui + buildArgs: + VITE_RPC: "emerynet.rpc.agoric.net" + VITE_BRIDGE_HREF: "" + VITE_BASE_URL: "kryha.kread.dev" + VITE_NETWORK_CONFIG: "https://emerynet.agoric.net/network-config" +deploy: + kustomize: + paths: + - ../deployment/emerynet/workloads + defaultNamespace: agoric-makefile-automation + diff --git a/frontend/skaffold.production.template.yaml b/frontend/skaffold.production.template.yaml index d45056230..8c0ff8525 100644 --- a/frontend/skaffold.production.template.yaml +++ b/frontend/skaffold.production.template.yaml @@ -9,11 +9,14 @@ build: concurrency: 0 push: true artifacts: - - image: $DOCKER_REPO + - image: eu.gcr.io/web3-335312/kread/frontend-production/frontend docker: dockerfile: Dockerfile.ui buildArgs: - VITE_DAPP_CONSTANTS_JSON: "" # TODO: provide actual value + VITE_RPC: "main.rpc.agoric.net" + VITE_BRIDGE_HREF: "" + VITE_BASE_URL: "kread.app" + VITE_NETWORK_CONFIG: "https://main.agoric.net/network-config" deploy: kustomize: paths: diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index a04f9b508..ca723a2e5 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -2,6 +2,7 @@ import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; import tsconfigPaths from "vite-tsconfig-paths"; import svgr from "vite-plugin-svgr"; +import { resolve } from "path"; // Import the 'resolve' function // https://vitejs.dev/config/ export default defineConfig({ @@ -21,6 +22,12 @@ export default defineConfig({ svgr(), ], build: { + rollupOptions: { + input: { + main: resolve(__dirname, "index.html"), // Specify the path to your index.html file + }, + }, target: "es2020", }, }); +