diff --git a/Dockerfile b/Dockerfile index 32f1f69eb..a9fa38afa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:16-alpine +FROM node:16-alpine AS build WORKDIR /tally-ho @@ -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 . diff --git a/README.md b/README.md index e3f292d39..1afc77fd1 100644 --- a/README.md +++ b/README.md @@ -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 git@github.com: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 diff --git a/firefox-build.sh b/firefox-build.sh index f6612d546..b1595b57c 100755 --- a/firefox-build.sh +++ b/firefox-build.sh @@ -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 diff --git a/webpack.config.ts b/webpack.config.ts index 10afd1471..d159f9bf3 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -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",