From 10837824929c7c2dd66068c97600f664c81d684d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Thu, 18 Jul 2024 12:29:45 +0200 Subject: [PATCH] chore(#1575): Provide pdf api url from the env variables --- .github/workflows/build-and-deploy-beta.yml | 1 + .github/workflows/build-and-deploy-dev.yml | 1 + .github/workflows/build-and-deploy-staging.yml | 1 + .github/workflows/build-and-deploy-test-stack.yml | 1 + .github/workflows/build-and-deploy-test.yml | 1 + CHANGELOG.md | 2 +- govtool/frontend/.env.example | 4 +++- govtool/frontend/Dockerfile | 1 + govtool/frontend/default.nix | 4 +++- govtool/frontend/src/pages/ProposalDiscussion.tsx | 1 + govtool/frontend/src/types/@intersect.mbo.d.ts | 1 + scripts/govtool/config.mk | 1 + scripts/govtool/config/templates/docker-compose.yml.tpl | 2 +- scripts/govtool/frontend.mk | 1 + 14 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-deploy-beta.yml b/.github/workflows/build-and-deploy-beta.yml index 6af69324b..a5cfa7fa7 100644 --- a/.github/workflows/build-and-deploy-beta.yml +++ b/.github/workflows/build-and-deploy-beta.yml @@ -57,6 +57,7 @@ jobs: TRAEFIK_LE_EMAIL: "admin+govtool@binarapps.com" USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }} IS_PROPOSAL_DISCUSSION_FORUM_ENABLED: ${{ inputs.isProposalDiscussionForumEnabled == 'enabled' }} + PDF_API_URL: ${{ secrets.PDF_API_URL}} steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/build-and-deploy-dev.yml b/.github/workflows/build-and-deploy-dev.yml index 7755dc10f..3c854f613 100644 --- a/.github/workflows/build-and-deploy-dev.yml +++ b/.github/workflows/build-and-deploy-dev.yml @@ -57,6 +57,7 @@ jobs: TRAEFIK_LE_EMAIL: "admin+govtool@binarapps.com" USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }} IS_PROPOSAL_DISCUSSION_FORUM_ENABLED: ${{ inputs.isProposalDiscussionForumEnabled == 'enabled' }} + PDF_API_URL: ${{ secrets.PDF_API_URL }} steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/build-and-deploy-staging.yml b/.github/workflows/build-and-deploy-staging.yml index 7534040d3..75a32f64e 100644 --- a/.github/workflows/build-and-deploy-staging.yml +++ b/.github/workflows/build-and-deploy-staging.yml @@ -60,6 +60,7 @@ jobs: TRAEFIK_LE_EMAIL: "admin+govtool@binarapps.com" USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }} IS_PROPOSAL_DISCUSSION_FORUM_ENABLED: ${{github.event_name == 'push' && 'false' || inputs.isProposalDiscussionForumEnabled == 'enabled'}} + PDF_API_URL: ${{ secrets.PDF_API_URL}} steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/build-and-deploy-test-stack.yml b/.github/workflows/build-and-deploy-test-stack.yml index bd59c79c7..f003258c8 100644 --- a/.github/workflows/build-and-deploy-test-stack.yml +++ b/.github/workflows/build-and-deploy-test-stack.yml @@ -26,6 +26,7 @@ jobs: PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }} APP_ENV: test + PDF_API_URL: ${{ secrets.PDF_API_URL}} steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/build-and-deploy-test.yml b/.github/workflows/build-and-deploy-test.yml index b2c99fd83..4e4c6ae06 100644 --- a/.github/workflows/build-and-deploy-test.yml +++ b/.github/workflows/build-and-deploy-test.yml @@ -60,6 +60,7 @@ jobs: TRAEFIK_LE_EMAIL: "admin+govtool@binarapps.com" USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }} IS_PROPOSAL_DISCUSSION_FORUM_ENABLED: ${{github.event_name == 'push' && 'false' || inputs.isProposalDiscussionForumEnabled == 'enabled'}} + PDF_API_URL: ${{ secrets.PDF_API_URL}} steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index fd05c0873..57239b6ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ changes. ### Added -- +- Add PDF_API_URL to the frontend config [Issue 1575](https://github.com/IntersectMBO/govtool/issues/1575) ### Fixed diff --git a/govtool/frontend/.env.example b/govtool/frontend/.env.example index 31ad2f00b..2d2ad1bc7 100644 --- a/govtool/frontend/.env.example +++ b/govtool/frontend/.env.example @@ -4,4 +4,6 @@ VITE_NETWORK_FLAG=0 VITE_SENTRY_DSN="" VITE_GTM_ID="" VITE_IS_DEV=true -VITE_USERSNAP_SPACE_API_KEY="" \ No newline at end of file +VITE_USERSNAP_SPACE_API_KEY="" +VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED="false" +VITE_PDF_API_URL="" \ No newline at end of file diff --git a/govtool/frontend/Dockerfile b/govtool/frontend/Dockerfile index 23fb5c1ed..3418c6506 100644 --- a/govtool/frontend/Dockerfile +++ b/govtool/frontend/Dockerfile @@ -8,6 +8,7 @@ ARG VITE_SENTRY_DSN ARG NPMRC_TOKEN ARG VITE_USERSNAP_SPACE_API_KEY ARG VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED='false' +ARG VITE_PDF_API_URL ENV NODE_OPTIONS=--max_old_space_size=8192 WORKDIR /src diff --git a/govtool/frontend/default.nix b/govtool/frontend/default.nix index 670f89c3b..6b9e9796c 100644 --- a/govtool/frontend/default.nix +++ b/govtool/frontend/default.nix @@ -4,6 +4,8 @@ , VITE_IS_DEV ? "true" , VITE_GTM_ID ? "" , VITE_SENTRY_DSN ? "" +, VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED ? "" +, VITE_PDF_API_URL ? "" , CARDANO_NETWORK ? "sanchonet" }: let @@ -29,7 +31,7 @@ let name = "govtool-website"; src = frontendSrc; buildInputs = [pkgs.yarn nodeModules]; - inherit VITE_BASE_URL VITE_IS_DEV VITE_GTM_ID VITE_SENTRY_DSN VITE_NETWORK_FLAG; + inherit VITE_BASE_URL VITE_IS_DEV VITE_GTM_ID VITE_SENTRY_DSN VITE_NETWORK_FLAG VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED VITE_PDF_API_URL; buildPhase = '' ln -s ${nodeModules}/libexec/voltaire-voting-app/node_modules node_modules yarn build diff --git a/govtool/frontend/src/pages/ProposalDiscussion.tsx b/govtool/frontend/src/pages/ProposalDiscussion.tsx index ae8301b7f..67ed9b667 100644 --- a/govtool/frontend/src/pages/ProposalDiscussion.tsx +++ b/govtool/frontend/src/pages/ProposalDiscussion.tsx @@ -49,6 +49,7 @@ export const ProposalDiscussionPillar = () => { } > |$(docker_user)|g" \ -e "s||$(repo_url)|g" \ -e "s||$${CSP_ALLOWED_HOSTS}|g" \ + -e "s||$${PDF_API_URL}|g" \ $< > $@ $(cardano_config_files): $(target_config_dir)/cardano-node/ diff --git a/scripts/govtool/config/templates/docker-compose.yml.tpl b/scripts/govtool/config/templates/docker-compose.yml.tpl index b73b22e02..27791df46 100644 --- a/scripts/govtool/config/templates/docker-compose.yml.tpl +++ b/scripts/govtool/config/templates/docker-compose.yml.tpl @@ -273,7 +273,7 @@ services: logging: *logging labels: - "traefik.enable=true" - - "traefik.http.middlewares.frontend-csp.headers.contentSecurityPolicy=default-src 'self'; img-src *.usersnap.com https://www.googletagmanager.com 'self' data:; script-src 'unsafe-inline' *.usersnap.com 'self' https://www.googletagmanager.com https://browser.sentry-cdn.com; style-src *.usersnap.com *.googleapis.com 'self' 'unsafe-inline' https://fonts.googleapis.com; connect-src *.usersnap.com https://s3.eu-central-1.amazonaws.com/upload.usersnap.com 'self' *.sentry.io *.google-analytics.com *.api.pdf.gov.tools; font-src *.usersnap.com *.gstatic.com 'self' https://fonts.gstatic.com data:; worker-src blob:" + - "traefik.http.middlewares.frontend-csp.headers.contentSecurityPolicy=default-src 'self'; img-src *.usersnap.com https://www.googletagmanager.com 'self' data:; script-src 'unsafe-inline' *.usersnap.com 'self' https://www.googletagmanager.com https://browser.sentry-cdn.com; style-src *.usersnap.com *.googleapis.com 'self' 'unsafe-inline' https://fonts.googleapis.com; connect-src *.usersnap.com https://s3.eu-central-1.amazonaws.com/upload.usersnap.com 'self' *.sentry.io *.google-analytics.com ; font-src *.usersnap.com *.gstatic.com 'self' https://fonts.gstatic.com data:; worker-src blob:" - "traefik.http.routers.to-frontend.rule=Host(``)" - "traefik.http.routers.to-frontend.entrypoints=websecure" - "traefik.http.routers.to-frontend.tls.certresolver=myresolver" diff --git a/scripts/govtool/frontend.mk b/scripts/govtool/frontend.mk index 2db555723..3881a2bcd 100644 --- a/scripts/govtool/frontend.mk +++ b/scripts/govtool/frontend.mk @@ -23,6 +23,7 @@ build-frontend: docker-login --build-arg VITE_USERSNAP_SPACE_API_KEY="$${USERSNAP_SPACE_API_KEY}" \ --build-arg VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED="$${IS_PROPOSAL_DISCUSSION_FORUM_ENABLED}" \ --build-arg NPMRC_TOKEN="$${NPMRC_TOKEN}" \ + --build-arg VITE_PDF_API_URL="$${PDF_API_URL}" \ $(root_dir)/govtool/frontend .PHONY: push-frontend