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

[Feat]: Passing ENV variables to preevy up #541

Open
1 task done
matteobad opened this issue Nov 8, 2024 · 2 comments
Open
1 task done

[Feat]: Passing ENV variables to preevy up #541

matteobad opened this issue Nov 8, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@matteobad
Copy link

What feature?

Maybe I missed it in the doc, and in the example the docker-compose has hardcoded env. In most setups we need to specify differente ENV based on the environment. Is there a way to do this?

Describe the solution you'd like

Ability to pass environment variables or file to the preevy up command and/or GitHub action

Describe alternatives you've considered

Configuring env on third party service and retrieve them on startup. Not sutable for every project

Additional context

No response

Add screenshots

No response

Record

  • I agree to follow this project's Code of Conduct
@matteobad matteobad added the enhancement New feature or request label Nov 8, 2024
@Yshayy
Copy link
Contributor

Yshayy commented Nov 9, 2024

Hey @matteobad, in Docker Compose, you can pass environment variables in multiple ways. Preevy supports them all:

environment:
  # Assign a fixed value to MY_ENV_VAR
  - MY_ENV_VAR=abc

  # Load the value of EXTERNAL_ENV_VAR from the host environment
  # and assign it to MY_ENV_VAR in the container
  - MY_ENV_VAR=${EXTERNAL_ENV_VAR}

  # Pass MY_ENV_VAR directly from the host environment to the container
  # (equivalent to MY_ENV_VAR=${MY_ENV_VAR} if MY_ENV_VAR exists in the host environment)
  - MY_ENV_VAR

  # Set MY_ENV_VAR to the value from the host if it exists, 
  # otherwise use "abc" as a default value in the container
  - MY_ENV_VAR=${MY_ENV_VAR:-abc}

In addition, docker compose support loading .env files:

env_file:
      - .env              # Base environment variables
      - .env.override     # Override specific values
      - ${ENV_NAME}.env   # Environment-specific variables (e.g., dev.env, prod.env)

You can also see more examples here #221 and in https://docs.docker.com/compose/how-tos/environment-variables/set-environment-variables

@matteobad
Copy link
Author

Hi @Yshayy, thank you for the quick reply!

I'm already using ENV in my docker-compose file, I just wasn't sure that running the preevy up command would make the ENVs available, and I couldn't find an example without hardcoded vars.

Maybe we could make it more clear in the docs somewhere? Anyway thanks for the great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants