From ef0dbb91bac64531b9ef94c6af27b36b2f0c19b2 Mon Sep 17 00:00:00 2001 From: PrivacyDev Date: Sat, 10 Dec 2022 00:12:57 -0500 Subject: [PATCH 1/5] added script to download and serve fonts locally by default --- Dockerfile | 3 ++- localizefonts.sh | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100755 localizefonts.sh diff --git a/Dockerfile b/Dockerfile index 68e50f0d..881f371a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,9 @@ COPY . . RUN --mount=type=cache,target=/root/.cache/yarn \ --mount=type=cache,target=/app/node_modules \ + pkg add curl && \ yarn install --prefer-offline && \ - yarn build && sed -i 's/fonts.gstatic.com/fonts.kavin.rocks/g' dist/assets/*.css + yarn build && ./localizefonts.sh FROM nginx:alpine diff --git a/localizefonts.sh b/localizefonts.sh new file mode 100755 index 00000000..1d211f19 --- /dev/null +++ b/localizefonts.sh @@ -0,0 +1,10 @@ +#/bin/sh + +base='https://fonts\.(gstatic\.com|kavin\.rocks)' +fonts=$(cat dist/assets/* | grep -Po "$base[^)]*" | sort | uniq) +for font in $fonts; do + file="dist/fonts$(echo $font | sed "s#$base##")" + mkdir -p "$(dirname "$file")" + curl -L "$font" -o "$file" +done +sed -i "s#$base#/fonts#g" dist/assets/* From 585605312f43b6aa10ea092af9b599e045cb4ae5 Mon Sep 17 00:00:00 2001 From: PrivacyDev Date: Mon, 12 Dec 2022 19:15:44 -0500 Subject: [PATCH 2/5] fixed bug in localizefonts.sh --- localizefonts.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/localizefonts.sh b/localizefonts.sh index 1d211f19..5456dfad 100755 --- a/localizefonts.sh +++ b/localizefonts.sh @@ -3,8 +3,8 @@ base='https://fonts\.(gstatic\.com|kavin\.rocks)' fonts=$(cat dist/assets/* | grep -Po "$base[^)]*" | sort | uniq) for font in $fonts; do - file="dist/fonts$(echo $font | sed "s#$base##")" + file="dist/fonts$(echo $font | sed -E "s#$base##")" mkdir -p "$(dirname "$file")" curl -L "$font" -o "$file" done -sed -i "s#$base#/fonts#g" dist/assets/* +sed -Ei "s#$base#/fonts#g" dist/assets/* From 54904fc6c75ac698497dfc9720bfb15c1286ba15 Mon Sep 17 00:00:00 2001 From: PrivacyDev Date: Sat, 17 Dec 2022 08:47:30 -0500 Subject: [PATCH 3/5] fixed shebang --- localizefonts.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/localizefonts.sh b/localizefonts.sh index 5456dfad..f3d189f1 100755 --- a/localizefonts.sh +++ b/localizefonts.sh @@ -1,4 +1,4 @@ -#/bin/sh +#!/bin/sh base='https://fonts\.(gstatic\.com|kavin\.rocks)' fonts=$(cat dist/assets/* | grep -Po "$base[^)]*" | sort | uniq) From 372df4d8f7907c7f72f3ffe66ac80f3e3a642dcb Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Mon, 2 Jan 2023 21:34:32 +0000 Subject: [PATCH 4/5] Add curl as dependency before. --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 881f371a..d005c367 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,11 +2,14 @@ FROM node:lts-alpine AS build WORKDIR /app/ +RUN --mount=type=cache,target=/var/cache/apk \ + apk add --no-cache \ + curl + COPY . . RUN --mount=type=cache,target=/root/.cache/yarn \ --mount=type=cache,target=/app/node_modules \ - pkg add curl && \ yarn install --prefer-offline && \ yarn build && ./localizefonts.sh From 07ac617fec2761c39e55fb0960b4c858888f2ce3 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Mon, 2 Jan 2023 21:41:28 +0000 Subject: [PATCH 5/5] Replace more build step stages. --- .github/workflows/deploy-azure.yml | 2 +- .github/workflows/docker-build.yml | 2 +- .github/workflows/ipfs-build.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-azure.yml b/.github/workflows/deploy-azure.yml index aabf7dce..873eb11b 100644 --- a/.github/workflows/deploy-azure.yml +++ b/.github/workflows/deploy-azure.yml @@ -24,7 +24,7 @@ jobs: ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig app_location: "/" # App source code path - app_build_command: "yarn build && sed -i 's/fonts.gstatic.com/fonts.kavin.rocks/g' dist/assets/*.css" + app_build_command: "yarn build && ./localizefonts.sh" api_location: "" # Api source code path - optional output_location: "dist" # Built app content directory - optional ###### End of Repository/Build Configurations ###### diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index e52ccb49..5cf8defa 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -17,7 +17,7 @@ jobs: with: cache: "yarn" - run: yarn install --prefer-offline - - run: yarn build --out-dir dist-ci && sed -i 's/fonts.gstatic.com/fonts.kavin.rocks/g' dist-ci/assets/*.css + - run: yarn build --out-dir dist-ci && ./localize-fonts.sh - name: Set up QEMU uses: docker/setup-qemu-action@v2 with: diff --git a/.github/workflows/ipfs-build.yml b/.github/workflows/ipfs-build.yml index 8797fcde..ccd1d8b3 100644 --- a/.github/workflows/ipfs-build.yml +++ b/.github/workflows/ipfs-build.yml @@ -17,7 +17,7 @@ jobs: with: cache: "yarn" - run: yarn install --prefer-offline - - run: yarn build && sed -i 's/fonts.gstatic.com/fonts.kavin.rocks/g' dist/assets/*.css && cp dist/index.html dist/ipfs-404.html + - run: yarn build && ./localizefonts.sh && cp dist/index.html dist/ipfs-404.html - uses: aquiladev/ipfs-action@v0.3.1-alpha.2 id: ipfs-add with: