Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#849] Configure sanchogov.tools sub-domain for the analytics service #868

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions .github/workflows/build-and-deploy-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,25 @@ jobs:
working-directory: ./scripts/govtool
env:
DBSYNC_POSTGRES_DB: "cexplorer"
DBSYNC_POSTGRES_USER: "postgres"
DBSYNC_POSTGRES_PASSWORD: "pSa8JCpQOACMUdGb"
DBSYNC_POSTGRES_USER: "postgres"
GA_CLIENT_EMAIL: ${{ secrets.GA_CLIENT_EMAIL }}
GA_PRIVATE_KEY: ${{ secrets.GA_PRIVATE_KEY }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }}
GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }}
GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }}
NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }}
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }}
TRAEFIK_LE_EMAIL: "[email protected]"
GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }}
GTM_ID: ${{ secrets.GTM_ID }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }}
PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
IP_ADDRESS_BYPASSING_BASIC_AUTH1: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH1 }}
IP_ADDRESS_BYPASSING_BASIC_AUTH2: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH2 }}
NEXT_PUBLIC_API_URL: "https://sanchogov.tools/api"
NEXT_PUBLIC_GA4_PROPERTY_ID: ${{ secrets.NEXT_PUBLIC_GA4_PROPERTY_ID }}
NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }}
PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }}
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }}
SENTRY_IGNORE_API_RESOLUTION_ERROR: "1"
TRAEFIK_LE_EMAIL: "[email protected]"
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }}
steps:
- name: Checkout code
Expand Down
20 changes: 13 additions & 7 deletions .github/workflows/build-and-deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,25 @@ jobs:
working-directory: ./scripts/govtool
env:
DBSYNC_POSTGRES_DB: "cexplorer"
DBSYNC_POSTGRES_USER: "postgres"
DBSYNC_POSTGRES_PASSWORD: "pSa8JCpQOACMUdGb"
DBSYNC_POSTGRES_USER: "postgres"
GA_CLIENT_EMAIL: ${{ secrets.GA_CLIENT_EMAIL }}
GA_PRIVATE_KEY: ${{ secrets.GA_PRIVATE_KEY }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }}
GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }}
GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }}
NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }}
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }}
TRAEFIK_LE_EMAIL: "[email protected]"
GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }}
GTM_ID: ${{ secrets.GTM_ID }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }}
PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
IP_ADDRESS_BYPASSING_BASIC_AUTH1: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH1 }}
IP_ADDRESS_BYPASSING_BASIC_AUTH2: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH2 }}
NEXT_PUBLIC_API_URL: "https://dev-sanchonet.govtool.byron.network/api"
NEXT_PUBLIC_GA4_PROPERTY_ID: ${{ secrets.NEXT_PUBLIC_GA4_PROPERTY_ID }}
NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }}
PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }}
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }}
SENTRY_IGNORE_API_RESOLUTION_ERROR: "1"
TRAEFIK_LE_EMAIL: "[email protected]"
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }}
steps:
- name: Checkout code
Expand Down
20 changes: 13 additions & 7 deletions .github/workflows/build-and-deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,25 @@ jobs:
working-directory: ./scripts/govtool
env:
DBSYNC_POSTGRES_DB: "cexplorer"
DBSYNC_POSTGRES_USER: "postgres"
DBSYNC_POSTGRES_PASSWORD: "pSa8JCpQOACMUdGb"
DBSYNC_POSTGRES_USER: "postgres"
GA_CLIENT_EMAIL: ${{ secrets.GA_CLIENT_EMAIL }}
GA_PRIVATE_KEY: ${{ secrets.GA_PRIVATE_KEY }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }}
GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }}
GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }}
NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }}
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }}
TRAEFIK_LE_EMAIL: "[email protected]"
GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }}
GTM_ID: ${{ secrets.GTM_ID }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }}
PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
IP_ADDRESS_BYPASSING_BASIC_AUTH1: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH1 }}
IP_ADDRESS_BYPASSING_BASIC_AUTH2: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH2 }}
NEXT_PUBLIC_API_URL: "https://staging.govtool.byron.network/api"
NEXT_PUBLIC_GA4_PROPERTY_ID: ${{ secrets.NEXT_PUBLIC_GA4_PROPERTY_ID }}
NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }}
PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }}
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }}
SENTRY_IGNORE_API_RESOLUTION_ERROR: "1"
TRAEFIK_LE_EMAIL: "[email protected]"
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }}
steps:
- name: Checkout code
Expand Down
20 changes: 13 additions & 7 deletions .github/workflows/build-and-deploy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,25 @@ jobs:
working-directory: ./scripts/govtool
env:
DBSYNC_POSTGRES_DB: "cexplorer"
DBSYNC_POSTGRES_USER: "postgres"
DBSYNC_POSTGRES_PASSWORD: "pSa8JCpQOACMUdGb"
DBSYNC_POSTGRES_USER: "postgres"
GA_CLIENT_EMAIL: ${{ secrets.GA_CLIENT_EMAIL }}
GA_PRIVATE_KEY: ${{ secrets.GA_PRIVATE_KEY }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }}
GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }}
GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }}
NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }}
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }}
TRAEFIK_LE_EMAIL: "[email protected]"
GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }}
GTM_ID: ${{ secrets.GTM_ID }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }}
PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
IP_ADDRESS_BYPASSING_BASIC_AUTH1: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH1 }}
IP_ADDRESS_BYPASSING_BASIC_AUTH2: ${{ secrets.IP_ADDRESS_BYPASSING_BASIC_AUTH2 }}
NEXT_PUBLIC_API_URL: "https://test-sanchonet.govtool.byron.network/api"
NEXT_PUBLIC_GA4_PROPERTY_ID: ${{ secrets.NEXT_PUBLIC_GA4_PROPERTY_ID }}
NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }}
PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }}
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }}
SENTRY_IGNORE_API_RESOLUTION_ERROR: "1"
TRAEFIK_LE_EMAIL: "[email protected]"
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }}
steps:
- name: Checkout code
Expand Down
6 changes: 3 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
flake-utils.lib.eachDefaultSystem (system:
let
defaultPkgs = import default_nixpkgs { inherit system; config.allowBroken = true; };
nodePkgs = import node_nixpkgs { inherit system; };
nodePkgs = import node_nixpkgs { inherit system; config.allowUnfree = true; };
frontend = nodePkgs.callPackage ./govtool/frontend { pkgs = nodePkgs; };
in
{
packages.scripts = defaultPkgs.callPackage ./scripts/govtool { pkgs = defaultPkgs; };
packages.infra = defaultPkgs.callPackage ./infra/terraform { pkgs = defaultPkgs; };
packages.scripts = defaultPkgs.callPackage ./scripts/govtool { pkgs = nodePkgs; };
packages.infra = defaultPkgs.callPackage ./infra/terraform { pkgs = nodePkgs; };
packages.backend = defaultPkgs.callPackage ./govtool/backend { pkgs = defaultPkgs; };
packages.frontendModules = frontend.nodeModules;
packages.frontend = frontend.staticSite;
Expand Down
6 changes: 6 additions & 0 deletions govtool/analytics-dashboard/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
NEXT_PUBLIC_GA4_PROPERTY_ID=
GOOGLE_APPLICATION_CREDENTIALS=
GA_CLIENT_EMAIL=
GA_PRIVATE_KEY=
SENTRY_IGNORE_API_RESOLUTION_ERROR=1
NEXT_PUBLIC_API_URL=
39 changes: 39 additions & 0 deletions govtool/analytics-dashboard/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local
.env
# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# Sentry Config File
.sentryclirc
7 changes: 7 additions & 0 deletions govtool/analytics-dashboard/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"useTabs": true
}
65 changes: 65 additions & 0 deletions govtool/analytics-dashboard/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
FROM node:18-alpine AS base

# Install dependencies only when needed
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi


# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Disabled telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1

RUN \
if [ -f yarn.lock ]; then yarn run build; \
elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production

# Disabled telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

# Automatically leverage output traces to reduce image size
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT 3000
# set hostname to localhost
ENV HOSTNAME "0.0.0.0"

# server.js is created by next build from the standalone output
CMD ["node", "server.js"]
Loading