Skip to content

feat: runtime env#712

Open
fmorency wants to merge 6 commits intomanifest-network:mainfrom
fmorency:runtime-env
Open

feat: runtime env#712
fmorency wants to merge 6 commits intomanifest-network:mainfrom
fmorency:runtime-env

Conversation

@fmorency
Copy link
Contributor

This pull request introduces a new runtime environment variable injection system for Docker deployments, allowing the app to be built once and configured at container start for any environment. It removes the need for .env files at build time, updates the environment variable access pattern in the codebase, and adds documentation for the new approach. The most important changes are grouped below.

Runtime Environment Injection for Docker:

  • Added docker-entrypoint.mjs script to collect all NEXT_PUBLIC_* environment variables at container start, write them to public/env-config.js as window.__ENV__, and start the Next.js server.
  • Modified Dockerfile to create a dummy .env at build, ensure public/ is writable, copy docker-entrypoint.mjs, and use it as the container entrypoint instead of directly starting the server. [1] [2] [3]
  • Removed the .env creation step from the GitHub Actions Docker build workflow, making the image environment-agnostic.

App Code Changes for New Env Pattern:

  • Updated config/env.ts to use a new getEnvVar() helper, reading variables from window.__ENV__ in the browser and process.env on the server, preventing Next.js from inlining env vars at build time. [1] [2]
  • Added synchronous loading of env-config.js in pages/_document.tsx to ensure window.__ENV__ is available before React hydrates.
  • Added a committed placeholder public/env-config.js for development and build consistency.

Documentation Updates:

  • Added detailed Docker instructions to README.md, explaining the new runtime env system and how to pass NEXT_PUBLIC_* variables at container start.
  • Introduced CLAUDE.md with project overview, architecture, env handling, and CI details for contributors and Claude Code.

fmorency and others added 2 commits February 19, 2026 14:26
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Build one Docker image and configure it at container start instead of
baking NEXT_PUBLIC_* vars at build time. docker-entrypoint.mjs writes
all NEXT_PUBLIC_* env vars into public/env-config.js, which is loaded
synchronously before React hydrates. config/env.ts reads from
window.__ENV__ on the client and process.env (dynamic key access) on
the server, so all 58 consumer files remain unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fmorency fmorency requested a review from Copilot February 19, 2026 20:08
@fmorency fmorency self-assigned this Feb 19, 2026
@vercel
Copy link

vercel bot commented Feb 19, 2026

@fmorency is attempting to deploy a commit to the Manifest Network's projects Team on Vercel.

A member of the Team first needs to authorize it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a runtime environment injection mechanism for Docker deployments so the Next.js app can be built once and configured at container start via NEXT_PUBLIC_* variables, rather than requiring build-time .env values.

Changes:

  • Adds a Docker entrypoint script that generates public/env-config.js from NEXT_PUBLIC_* variables at container start.
  • Updates app-side env access to read from window.__ENV__ (client) or process.env (server) to avoid build-time inlining.
  • Updates Docker image build/run workflow and documentation to support runtime configuration.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
docker-entrypoint.mjs Generates public/env-config.js from runtime NEXT_PUBLIC_* variables before starting the server.
Dockerfile Switches container startup to run the entrypoint script and ensures public/ is writable.
config/env.ts Introduces getEnvVar() and migrates config reads away from static process.env.NEXT_PUBLIC_* access.
pages/_document.tsx Loads /env-config.js synchronously before hydration to populate window.__ENV__.
public/env-config.js Adds a committed placeholder window.__ENV__ = {} for build/dev consistency.
README.md Documents Docker runtime env injection and provides build/run instructions.
.github/workflows/_docker-build.yml Removes build-time .env generation so images are environment-agnostic.
CLAUDE.md Adds contributor/architecture documentation including the new env handling approach.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

fmorency and others added 3 commits February 19, 2026 15:22
…mple

Move the Window.__ENV__ augmentation from config/env.ts to global.d.ts
where other Window globals are declared. Remove the shell comment in
the README docker run example that broke line continuation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Formik async validation can be slow on CI runners, causing the test
to exceed the default 5s timeout.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The waitFor polling for the button disabled state would hang
indefinitely on slow CI runners. Instead, wait for Formik validation
to complete (error tooltip appears), then assert button state
synchronously.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

❌ Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
config/env.ts 95.83% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants