Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

258
Visualizações
How to update environment variables without rebuilding the React app image

I'm building a dockerized React application and need to define some environment variables for API URLs. However, React inject those variables in the build phase, so I need to rebuild the whole image every time the environment changes. This slows down my pipeline, as I can't reuse the same app image for homologation and production.

I've searched for some patterns and I'm now using a JS config file to inject the environment on the fly, but it doesn't look very straightforward. Does someone know a better way to handle this problem?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I had the same problem recently, then I published some packages: @import-meta-env/* to npm to solve the problem.

This plugin exposes environment variables on a special import.meta.env object (heavily inspired by Vite).

During production it will be statically replaced with a placeholder instead of current environment variables.

Thus we can run a script anywhere to populating files with environment variables from the system.

You can see more info at https://iendeavor.github.io/import-meta-env/ .

I also created a Docker example: https://github.com/iendeavor/import-meta-env/tree/main/packages/examples/docker-starter-example .

Hope this helps someone who needs it.

about 4 years ago · Juan Pablo Isaza Relatório

0

Yes indeed this is a problem with environment variables. What you want to achieve can be done with a service that is commonly called "Remote Config" or "Config as a service - CaaS". This service notifies your application that some external data has changed. I would highly recommend LaunchDarkly or Firebase but you can always choose to build it on your own (not a fast solution though). The only way to avoid multiple environment builds is by applying rules on the CaaS and modify the responses based on who requests (eg, based on the request's "Origin" header)

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda