Skip to content

Remove APP_ENV=dev in Dockerfile and compose.override.yaml taking precedence over dotenv variable #852

@ToshY

Description

@ToshY

Problem

The Dockerfile has hardcoded ENV APP_ENV=dev (for dev stage), and the compose.override.yaml also passes the APP_ENV to the container as environment variable.

When you start up the service (with docker compose up -d), it will pass the APP_ENV (from the .env) to the container through the compose.override.yaml (and defaults to dev if not set).

As real environment variables will always have precedence over dotenv variables, this means that even when the APP_ENV changed from dev to prod in the .env, it will not take effect until the docker container is recreated.

The behavior of APP_ENV is counter-intuitive with regards on how Symfony normally handles this, because normally when changes are made in the dotenv files, these changes are reflected immediately (in the next request). The Dockerfile/compose config should not pass environment variables that are also used in Symfony dotenvs for development purposes.

Suggestion

  • Remove ENV APP_ENV=dev from the frankenphp_dev stage.
    • The ENV APP_ENV=prod can probably be kept.
  • Remove APP_ENV: "${APP_ENV:-dev}" from compose.override.yaml

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions