Skip to content

Commit e19b7da

Browse files
authored
Extension: docker image and build instructions for firefox (#1414)
* feat(extension): docker image and build instructions for firefox * feat(firefox): separating build in different stages and updating docs * feat: ensure amd64 architecture * feat: tweaking options on webpack
1 parent 8a4ffed commit e19b7da

File tree

3 files changed

+59
-47
lines changed

3 files changed

+59
-47
lines changed

apps/extension/FIREFOX_README.md

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,25 @@ exactly as they are described below.
1313

1414
## Build instructions
1515

16-
**NOTE**: You _must_ use `yarn` to install dependencies! This is due to the fact that this is configured as a monorepo
17-
using yarn workspaces. If you install via `npm install` or `npm i`, it will not resolve dependencies correctly.
18-
19-
If you don't already have Node v22 LTS and NPM v10, please follow these [instructions](#setting-up-node-and-npm)
20-
21-
These instructions should work for the default reviewer build environment.
16+
1. Certify that Docker 27+ is installed in your system before proceeding with the build:
2217

2318
```bash
24-
sudo apt install protobuf-compiler build-essential curl pkg-config libssl-dev binaryen -y
25-
curl https://sh.rustup.rs -sSf | sh
26-
27-
# Proceed with standard installation when prompted
28-
29-
# Make sure to pull cargo into your current environment:
30-
. "$HOME/.cargo/env"
31-
32-
# You must use yarn to install dependencies:
33-
npm install -g yarn
34-
export PUPPETEER_SKIP_DOWNLOAD=true
35-
36-
# Run yarn to install dependencies
37-
yarn
19+
docker --version
20+
```
3821

39-
# Move into extension app directory
40-
cd apps/extension
22+
2. From the **repository root**, build the Docker image:
4123

42-
# Build wasm dependency:
43-
yarn wasm:build
24+
```bash
25+
docker build . --target firefox -t namada-keychain-firefox -f docker/extension/Dockerfile
4426
```
4527

46-
Then, issue the final build command for the Firefox add-on:
28+
3. Wait for the build to complete, and then copy the files from the container by executing the following command in the **repository root**:
4729

4830
```bash
49-
# Build the addon:
50-
yarn build:firefox
31+
docker run --rm -v ./apps/extension/build:/shared namada-keychain-firefox cp -r /app/apps/extension/build/. /shared/
5132
```
5233

53-
The resulting extension is the ZIP file in `apps/extension/build/firefox`.
34+
4. The resulting extension is the ZIP file in `apps/extension/build/firefox`.
5435

5536
[ [Table of Contents](#table-of-contents) ]
5637

@@ -63,25 +44,16 @@ This build was produced using the following environment:
6344
- Ubuntu 24.04 LTS (Desktop edition)
6445
- 10GB of system memory (RAM)
6546
- 6 cores of vCPU
66-
- Node 22 LTS and npm 10
6747
- 35GB of storage
48+
- Docker version 27+ installed and running
6849

6950
Please ensure that this matches your environment!
7051

7152
[ [Table of Contents](#table-of-contents) ]
7253

73-
### Setting up Node and NPM
74-
75-
```bash
76-
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
77-
78-
# Enable nvm in current shell
79-
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
80-
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
54+
### Installing Docker
8155

82-
# Install v22 LTS
83-
nvm install v22.0.0
84-
```
56+
If Docker is not currently installed in your environment, please refer to the [instructions of the official Docker documentation](https://docs.docker.com/engine/install/ubuntu/).
8557

8658
[ [Table of Contents](#table-of-contents) ]
8759

apps/extension/webpack.config.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ const { getProcessEnv } = require("@namada/config/webpack.js");
1313
// Load .env from namadillo:
1414
require("dotenv").config({ path: "./.env" });
1515

16-
const {
17-
NODE_ENV,
18-
TARGET,
19-
BUNDLE_ANALYZE,
20-
BETA_RELEASE: isBeta,
21-
} = process.env;
16+
const { NODE_ENV, TARGET, BUNDLE_ANALYZE, BETA_RELEASE: isBeta } = process.env;
2217

2318
const OUTPUT_PATH = resolve(__dirname, `./build/${TARGET}`);
2419
const MANIFEST_VERSION = TARGET === "firefox" ? "v2" : "v3";
@@ -159,14 +154,18 @@ module.exports = {
159154
path: OUTPUT_PATH,
160155
//TODO: this might lead to problems with caching
161156
filename: "[name].namada.js",
157+
chunkFilename: "[id].[contenthash].js",
158+
hashFunction: "xxhash64",
162159
},
163160
module: {
164161
rules: [
165162
{
166163
test: /\.tsx?$/,
167164
loader: "ts-loader",
168165
exclude: /node_modules/,
169-
options: {},
166+
options: {
167+
happyPackMode: false, // Ensure single-threaded processing
168+
},
170169
},
171170
{
172171
test: /\.css$/i,
@@ -226,4 +225,9 @@ module.exports = {
226225
// We want to ignore wasm-bindgen-rayon circular dependency warning
227226
warningsFilter: [/dependency between chunks.+wasm-bindgen-rayon/],
228227
},
228+
optimization: {
229+
minimize: false,
230+
moduleIds: "deterministic", // Ensures consistent module IDs
231+
chunkIds: "deterministic", // Ensures consistent chunk IDs
232+
},
229233
};

docker/extension/Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM --platform=linux/amd64 rust:1.79 AS builder
2+
3+
WORKDIR /app
4+
5+
# Installing required packages
6+
RUN apt update && apt install -y nodejs npm clang pkg-config libssl-dev protobuf-compiler curl
7+
RUN npm install -g yarn
8+
RUN rustup target add wasm32-unknown-unknown
9+
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -y
10+
11+
# Copying packages and scripts related to the monorepo
12+
COPY .yarnrc.yml tsconfig.base.json package.json yarn.lock .
13+
COPY ./.yarn ./.yarn
14+
COPY ./packages ./packages
15+
COPY ./scripts ./scripts
16+
COPY ./apps/extension/package.json ./apps/extension/package.json
17+
18+
# Installing packages
19+
RUN yarn
20+
WORKDIR /app/apps/extension
21+
22+
# Building wasm files
23+
COPY ./apps/extension/scripts ./scripts
24+
RUN yarn wasm:build
25+
26+
# Building extension dist files
27+
COPY ./apps/extension .
28+
RUN yarn
29+
30+
FROM builder AS firefox
31+
RUN yarn build:firefox
32+
33+
FROM builder AS chrome
34+
RUN yarn build:chrome
35+
36+

0 commit comments

Comments
 (0)