Skip to content

Build is dependent on a committed ENV file, and doesn't obey system ENV vars for GQL url #718

@mikemurray

Description

@mikemurray

Type: critical

This is a blocker for releases

Describe the bug

The BUILD_GRAPHQL_URL and/or EXTERNAL_GRAPHQL_URL env var is being baked into the JS bundle, likely due to the Next.js / webpack / static build. This bakes unchangeable configuration into the app, which leads to the built docker image on docker hub, being useless if you aren't using the default variables.

Part of the solution for enabling the Next.js static build was maintaining a .env.prod to supply those variables at build time for the production build. This env file is an anti-pattern for the following reasons.

  1. Promotes a dangerous practice of committing environment vars to a repo in a plain text file.
  2. Ties configuration to dev/prod when the build should have not care which system it's building for. The built app should run the same if you point it to your dev or production API.

ENV vars should always come from the system, and never be in a file that is committed to source control. The .env and .env.example files are a convenience local development only.

Because of the .env.prod file and the Next.js static build process, we're not able to use our generic Docker image published to Docker hub to run in our test environments, and generic users cannot use it as is without rebuilding.

Expected behavior

  • Do not require a static build in Next.js. This might be related to Optionally allow blocking fallback rendering #716
  • Remove .env.prod and make the build not dependent on that file. It should get its vars from the environment, whether you put them there in a prefix to the command, or cat them into the env, or set them in CI.
  • Fix the issue where the GraphQL urls are being baked into the built JS bundle.
    • Maybe proxy GraphQL requests through a Next.js API route so we can take advantage of system environment vars
    • Somehow make sure config doesn't get bundled

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugFor issues that describe a defect or regression in the released softwarepriority highseverity high

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions