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

feat: dockerize app with hyperchains configurable at runtime #189

Merged
merged 1 commit into from
Aug 14, 2024
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
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,33 @@ jobs:
VITE_FIREBASE_PROJECT_ID=zksync-dapp-wallet-v2 \
npx semantic-release || true

docker:
name: Build Docker
runs-on: ubuntu-latest
needs: publish
if: ${{ github.ref == 'refs/heads/main' && needs.publish.outputs.releaseVersion != '' }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
push: true
tags: |
matterlabs/dapp-portal:latest
matterlabs/dapp-portal:${{ needs.publish.outputs.releaseVersion }}
file: Dockerfile
no-cache: true

staging:
name: Deploy to Staging
Expand Down
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:18.17.1-alpine AS base-stage

WORKDIR /usr/src/app
COPY package*.json ./

FROM base-stage AS build-stage
RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*
RUN npm cache clean --force && npm install
COPY . .
RUN npm run generate

FROM base-stage AS production-stage
COPY --from=build-stage /usr/src/app/.output/public ./dist
RUN npm i -g http-server

ARG PORT=3000
ENV PORT=${PORT}

WORKDIR /usr/src/app/dist

CMD http-server -p $PORT -c-1 --proxy="http://127.0.0.1:$PORT/index.html?"
1 change: 1 addition & 0 deletions composables/usePortalRuntimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ export const usePortalRuntimeConfig = () => {
}
: undefined,
},
hyperchainsConfig: runtimeConfig?.hyperchainsConfig,
};
};
2 changes: 1 addition & 1 deletion data/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const publicChains: ZkSyncNetwork[] = [
];

const getHyperchains = (): ZkSyncNetwork[] => {
const hyperchains = Hyperchains as Config;
const hyperchains = portalRuntimeConfig.hyperchainsConfig || (Hyperchains as Config);
return hyperchains.map((e) => {
const network: ZkSyncNetwork = {
...e.network,
Expand Down
11 changes: 7 additions & 4 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { type Config as HyperchainsConfig } from "@/scripts/hyperchains/common";

export type Hash = `0x${string}`;

export type TokenPrice = number | undefined;
Expand Down Expand Up @@ -132,7 +134,7 @@ declare global {
track: (eventName: string, params?: unknown) => void;
initialized: boolean;
};
'##runtimeConfig'?: {
"##runtimeConfig"?: {
nodeType?: string;
walletConnectProjectId?: string;
ankrToken?: string;
Expand All @@ -141,8 +143,9 @@ declare global {
rudder?: {
key: string;
dataplaneUrl: string;
}
}
}
};
};
hyperchainsConfig?: HyperchainsConfig;
};
}
}
Loading