Skip to content

Add prod_envs option for custom production Mix environments#219

Open
johns10 wants to merge 1 commit intoburrito-elixir:mainfrom
Code-My-Spec:prod-envs-option
Open

Add prod_envs option for custom production Mix environments#219
johns10 wants to merge 1 commit intoburrito-elixir:mainfrom
Code-My-Spec:prod-envs-option

Conversation

@johns10
Copy link
Copy Markdown

@johns10 johns10 commented Mar 30, 2026

Summary

  • Add a prod_envs option to the burrito release config that controls which Mix environments are treated as production builds
  • Defaults to [:prod] for full backward compatibility
  • Fixes builds for projects using custom production environments like :prod_cli

Problem

is_prod/1 in PackAndBuild is hardcoded to check Mix.env() == :prod. Projects that use custom production environments (e.g. :prod_cli for building a CLI binary alongside a web app from the same codebase) always get IS_PROD=0, causing the Zig launcher to skip payload extraction and the release to silently fail to boot.

This is common when the same Elixir project needs different compile-time configs for different deployment targets (e.g. SQLite for CLI vs Postgres for web).

Solution

# In release config:
burrito: [
  prod_envs: [:prod, :prod_cli],
  targets: [...]
]

The prod_envs option accepts a list of atoms. When Mix.env() matches any entry, IS_PROD is set to "1". The default [:prod] preserves existing behavior.

Test plan

  • Verified IS_PROD=1 in Zig build env with prod_envs: [:prod, :prod_cli]
  • Verified Burrito binary extracts payload and boots successfully
  • Verified default behavior unchanged (:prod still works without the option)

🤖 Generated with Claude Code

Burrito's is_prod check is hardcoded to `Mix.env() == :prod`, which
fails for projects using custom production environments like :prod_cli
(common when the same codebase produces both a web app and a CLI binary
with different compile-time configs).

Add a `prod_envs` option to the burrito release config that defaults to
`[:prod]` for backward compatibility. Projects with custom envs can pass
their own list:

    burrito: [
      prod_envs: [:prod, :prod_cli],
      targets: [...]
    ]

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
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.

1 participant