From 31707979d461f7e834473e795663fb73158a8264 Mon Sep 17 00:00:00 2001 From: Lukasz Kosiak Date: Wed, 3 Sep 2025 09:28:57 +0200 Subject: [PATCH] zilliqa js package publish containerized --- README.md | 58 +++++++++++++++++------------------- build_and_publish.Dockerfile | 31 +++++++++++++++++++ zilliqa/js/.dockerignore | 28 +++++++++++++++++ 3 files changed, 87 insertions(+), 30 deletions(-) create mode 100644 build_and_publish.Dockerfile create mode 100644 zilliqa/js/.dockerignore diff --git a/README.md b/README.md index 44c8e1a39..fe4bc0a29 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,34 @@ following table is a place holder: | `//products/ceres` | zilliqa.com/apps | | | `//products/neo-savant` | ide.zilliqa.com | | +#### Building and publishing `zilliqa-js` + +To publish the `zilliqa-js` packages, you can use the provided Dockerfile to ensure a consistent build environment. + +First, build the Docker image: + +```sh +docker build -t zilliqa_js_publish -f build_and_publish.Dockerfile . +``` + +Then, run the container in interactive mode: + +```sh +docker run --rm -it zilliqa_js_publish sh +``` + +Finally, from within the container's shell, publish the packages using `pnpm`. First run it with `--dry-run` to test publish without publishing anything. + +```sh +pnpm publish --dry-run +``` + +If everything looks correct then run + +```sh +pnpm publish +``` + ## Building To disable our git queries on build, set the `DISABLE_WORKSPACE_STATUS` @@ -118,36 +146,6 @@ which is served on port `80`. #### Building libraries -#### Building and publishing `zilliqa-js` - -Checkout out the repository. First ensure that tests are passing: - -```sh -bazelisk test //zilliqa/js/... -``` - -Next navigate to the `zilliqa/js` folder. If you have not done so, install all -dependencies: - -```sh -pnpm i -``` - -Then build all libraries: - -```sh -pnpm -r build -``` - -Finally, publish: - -```sh -pnpm -r publish -``` - -Add `--dry-run` in the event you want to test publish without publishing -anything. - #### Building and running Docker images For the purpose of building Docker images, you do not need Docker installed diff --git a/build_and_publish.Dockerfile b/build_and_publish.Dockerfile new file mode 100644 index 000000000..214e8b2de --- /dev/null +++ b/build_and_publish.Dockerfile @@ -0,0 +1,31 @@ +# Use the official Node.js 18 image as the base +FROM node:18 + +# Set the working directory inside the container +WORKDIR /app + +# Install Python and build tools required for native dependencies +RUN apt-get update && apt-get install -y python3 build-essential + +# Install pnpm version 8.x globally, which is compatible with lockfileVersion 6.0 +RUN npm install -g pnpm@8 + +# Copy package.json and pnpm-lock.yaml to the working directory +COPY pnpm-lock.yaml . +COPY tsconfig.base.json . +COPY package.json . + +# Generate the pnpm-workspace.yaml file with the specified content +RUN echo 'packages:\n - "zilliqa/js/account"\n - "zilliqa/js/blockchain"\n - "zilliqa/js/contract"\n - "zilliqa/js/core"\n - "zilliqa/js/crypto"\n - "zilliqa/js/proto"\n - "zilliqa/js/subscriptions"\n - "zilliqa/js/typings"\n - "zilliqa/js/util"\n - "zilliqa/js/zilliqa"' > pnpm-workspace.yaml + +COPY zilliqa/js zilliqa/js/ + +# Install project dependencies. +RUN pnpm -r install --frozen-lockfile + +# Build the project +ENV NODE_OPTIONS=--max-old-space-size=4096 +RUN for pkg in zilliqa/js/typings zilliqa/js/core zilliqa/js/proto zilliqa/js/util zilliqa/js/crypto zilliqa/js/account zilliqa/js/blockchain zilliqa/js/contract zilliqa/js/subscriptions zilliqa/js/zilliqa; do echo "Building $pkg..."; pnpm --dir "$pkg" build; done + +# See Readme > Building and publishing `zilliqa-js` for the complete publishing process. +CMD ["echo", "1"] diff --git a/zilliqa/js/.dockerignore b/zilliqa/js/.dockerignore new file mode 100644 index 000000000..7e415bdf7 --- /dev/null +++ b/zilliqa/js/.dockerignore @@ -0,0 +1,28 @@ +# Dependencies +node_modules +/npm-debug.log +.npm + +# Node.js specific +npm-debug.log* +yarn-error.log* + +# Git ignore +.git +.gitignore + +# OS generated files +.DS_Store +.vscode +.idea +.env + +# Build artifacts +dist +build +*.log + +# Test files +coverage +*.test.js +*.spec.js \ No newline at end of file