Skip to content

Commit

Permalink
Changed the build for the firefox browser (#3733)
Browse files Browse the repository at this point in the history
In new versions the extension was simply not built for this browser.
Changed the build scripts and made them cross-managers.
Now it can be compiled not only by docker.

In general, everything works, except probably the main thing - sign in
at dapps.
If it ever gets fixed it will be great

Latest build:
[extension-builds-3733](https://github.com/tahowallet/extension/suites/20259618358/artifacts/1209187521)
(as of Wed, 31 Jan 2024 15:25:58 GMT).
  • Loading branch information
Shadowfiend authored Apr 13, 2024
2 parents 7dcf9f8 + 4393396 commit 66a1456
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 23 deletions.
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16-alpine
FROM node:16-alpine AS build

WORKDIR /tally-ho

Expand All @@ -8,4 +8,9 @@ RUN mv .env.prod .env
RUN apk add --no-cache python3 py3-pip git make bash && ln -sf python3 /usr/bin/python
# sqlite compile throws an error during install, but it does not cause any problem so we are ignoring it
RUN yarn install --frozen-lockfile || true
RUN yarn build --config-name firefox
ENV SUPPORT_BROWSER="firefox"
RUN yarn build

FROM scratch AS dist

COPY --from=build /tally-ho/dist .
40 changes: 29 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,17 +334,35 @@ ui/ # @tallyho/tally-ui package

Firefox requires to upload source code if minifier is used and to be able to compile identical output to the uploaded package. Our builds are environment dependent at the moment because of the minification and source map process. Long term solution will be to upgrade our build process to be able to produce identical file assets, but until then we use Docker.

- install and setup docker: https://docs.docker.com/get-docker/
- git clone [email protected]:tallycash/extension.git tallyho-firefox
- cd tallyho-firefox
- git checkout tags/latest_release-tag
- .env.prod: fill in the prod API keys
- `./firefox-build.sh`
- mv firefox.zip ../
- git clean -fdx
- rm -rf .git
- cd ..
- zip -r tallyho-firefox.zip tallyho-firefox
1. Install and setup container manger, like at [nerdctl](https://github.com/containerd/nerdctl),[podman](https://podman.io/) or [docker](https://www.docker.com/)
2. Clone git repository

```sh
git clone https://github.com:tallycash/extension.git tallyho-firefox
```

3. Change the directory

```sh
cd tallyho-firefox
git checkout tags/latest_release-tag
```

4. Fill the production keys `.env.prod` file

5. Run build script

```sh
./firefox-build.sh
```

6. Archive it

```sh
zip -r tallyho-firefox.zip dist/firefox
```

7. You can delete everything if you want except for the archive

## Localization

Expand Down
27 changes: 17 additions & 10 deletions firefox-build.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
#!/bin/bash
#!/bin/env sh

if command -v nerdctl &> /dev/null; then
ctrmanager=nerdctl
elif command -v docker &> /dev/null; then
ctrmanager=docker
elif command -v podman &> /dev/null; then
ctrmanager=podman
else
echo "Installing a container manager" >&2
exit
fi

echo "--- Let's clean up from earlier ---"
rm firefox.zip
docker container rm -f tally-ho-container || true
docker image rm --force tally-ho-image:latest || true
rm -rf dist
$ctrmanager image rm --force tally-ho-image:latest || true

echo "--- Build extension ---"
docker build --no-cache -t tally-ho-image:latest .
docker create --name tally-ho-container tally-ho-image

echo "--- Copy build output to host ---"
docker cp tally-ho-container:/tally-ho/dist/firefox.zip ./firefox.zip
$ctrmanager build -t tally-ho-image:latest --output=dist --target=dist .

echo "--- Let's clean up ---"
docker container rm -f tally-ho-container || true
docker image rm --force tally-ho-image:latest || true

$ctrmanager image rm --force tally-ho-image:latest || true
4 changes: 4 additions & 0 deletions webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import "dotenv-defaults/config"

const supportedBrowsers = ["chrome"]

if (process.env.SUPPORT_BROWSER === "firefox") {
supportedBrowsers.push("firefox")
}

// Replicated and adjusted for each target browser and the current build mode.
const baseConfig: Configuration = {
devtool: "source-map",
Expand Down

0 comments on commit 66a1456

Please sign in to comment.