Skip to content

Commit b5cc715

Browse files
committedJan 30, 2024
refactor: now extension for firefox can be building, you can also use alternatives to docker
1 parent aeaba91 commit b5cc715

File tree

4 files changed

+57
-23
lines changed

4 files changed

+57
-23
lines changed
 

‎Dockerfile

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:16-alpine
1+
FROM node:16-alpine AS build
22

33
WORKDIR /tally-ho
44

@@ -8,4 +8,9 @@ RUN mv .env.prod .env
88
RUN apk add --no-cache python3 py3-pip git make bash && ln -sf python3 /usr/bin/python
99
# sqlite compile throws an error during install, but it does not cause any problem so we are ignoring it
1010
RUN yarn install --frozen-lockfile || true
11-
RUN yarn build --config-name firefox
11+
ENV SUPPORT_BROWSER="firefox"
12+
RUN yarn build
13+
14+
FROM scratch AS dist
15+
16+
COPY --from=build /tally-ho/dist .

‎README.md

+29-11
Original file line numberDiff line numberDiff line change
@@ -334,17 +334,35 @@ ui/ # @tallyho/tally-ui package
334334

335335
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.
336336

337-
- install and setup docker: https://docs.docker.com/get-docker/
338-
- git clone git@github.com:tallycash/extension.git tallyho-firefox
339-
- cd tallyho-firefox
340-
- git checkout tags/latest_release-tag
341-
- .env.prod: fill in the prod API keys
342-
- `./firefox-build.sh`
343-
- mv firefox.zip ../
344-
- git clean -fdx
345-
- rm -rf .git
346-
- cd ..
347-
- zip -r tallyho-firefox.zip tallyho-firefox
337+
1. Install and setup container manger, like at [nerdctl](https://github.com/containerd/nerdctl),[podman](https://podman.io/) or [docker](https://www.docker.com/)
338+
2. Clone git repository
339+
340+
```sh
341+
git clone https://github.com:tallycash/extension.git tallyho-firefox
342+
```
343+
344+
3. Change the directory
345+
346+
```sh
347+
cd tallyho-firefox
348+
git checkout tags/latest_release-tag
349+
```
350+
351+
4. Fill the production keys `.env.prod` file
352+
353+
5. Run build script
354+
355+
```sh
356+
./firefox-build.sh
357+
```
358+
359+
6. Archive it
360+
361+
```sh
362+
zip -r tallyho-firefox.zip dist/firefox
363+
```
364+
365+
7. You can delete everything if you want except for the archive
348366

349367
## Localization
350368

‎firefox-build.sh

+17-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
#!/bin/bash
1+
#!/bin/env sh
2+
3+
if command -v nerdctl &> /dev/null; then
4+
ctrmanager=nerdctl
5+
elif command -v docker &> /dev/null; then
6+
ctrmanager=docker
7+
elif command -v podman &> /dev/null; then
8+
ctrmanager=podman
9+
else
10+
echo "Installing a container manager" >&2
11+
exit
12+
fi
213

314
echo "--- Let's clean up from earlier ---"
415
rm firefox.zip
5-
docker container rm -f tally-ho-container || true
6-
docker image rm --force tally-ho-image:latest || true
16+
rm -rf dist
17+
$ctrmanager image rm --force tally-ho-image:latest || true
718

819
echo "--- Build extension ---"
9-
docker build --no-cache -t tally-ho-image:latest .
10-
docker create --name tally-ho-container tally-ho-image
11-
12-
echo "--- Copy build output to host ---"
13-
docker cp tally-ho-container:/tally-ho/dist/firefox.zip ./firefox.zip
20+
$ctrmanager build -t tally-ho-image:latest --output=dist --target=dist .
1421

1522
echo "--- Let's clean up ---"
16-
docker container rm -f tally-ho-container || true
17-
docker image rm --force tally-ho-image:latest || true
23+
24+
$ctrmanager image rm --force tally-ho-image:latest || true

‎webpack.config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import "dotenv-defaults/config"
1818

1919
const supportedBrowsers = ["chrome"]
2020

21+
if (process.env.SUPPORT_BROWSER == "firefox") {
22+
supportedBrowsers.push("firefox")
23+
}
24+
2125
// Replicated and adjusted for each target browser and the current build mode.
2226
const baseConfig: Configuration = {
2327
devtool: "source-map",

0 commit comments

Comments
 (0)
Please sign in to comment.