How to pass env variables to Angular App on Jboss - environment-variables

I have an Angular 5 application packaged as a war file and deployed on Jboss server. What is the best way to pass a parameter to the application? e.g. I want to pass environment as test , qa , prod based on the various environments. Based on the parameter passed I would like to use appropriate environment.ts file. On local it is easy to do just by ng serve --env test command since I am using http-server on local. However, that is not possible to do on Jboss. I do not think passing a JVM parameter will be an option. Please let me know your ideas.

Related

How do I set environment variables to Next.js (SSR) after it is built?

I have this Next.js app (using SSR, using next start) which communicates with a server externally, and the server URL would have to be dynamic. This information, among other things, are dynamic variables that I would probably only have after initial deployment.
I have currently dockerized this Next.js app, so it gets built, then pushed to Docker Hub.
The "happy-flow" for the end user who would be using my app is that they should be able to pull the docker image of the prebuilt frontend, pass an env_file through docker-compose and just be able to use it as they wish.
All the examples (this and this) I've seen have explained how to pass ENV to Next.js but the ENV has to be passed during build time, which defeats the purpose of portability.
I was able to resolve this issue by making use of this package (react-env), which isn't the most ideal solution but works for now.
It has a couple of setup steps and opinionated configuration to it, but works as expected for anyone who's looking for a solution to pass env vars after the Next.js app has been built.

Flutter web read custom environment vairable from Docker

We have built an app with flutter web and want to deploy it on different servers ( staging and prod ) with docker swarm as a part of a backend. The same image should be executable in both environments as we have to change the URLs we use. I'm looking for a possibility to set an environment variable in my docker-compose file which then can be read within the flutter app at runtime. By googling I only found solutions with static files or Gradle. But we don't use both.

aspnet core 2.2 web app environment variables not changing in docker

I've got an ASP.NET core 2.2 web app that I have enabled docker support for. I have created a test app here for review here.
I am running it in VS with Docker locally. I want to add environment variables/secrets to the app settings secrets in order to override the values in the appsettings.json file. In order to do this locally, I have tried changing values in:
launchsettings.json
Dockerfile
however, for both of these, when I attach to my docker instance and printenv the variable values, I find that the variable for ASPNETCORE_ENVIRONMENT still shows up as Development.
I am attaching to the running container like this:
docker exec -t -i 4c05 /bin/bash
I have searched all files in my solution. I can't find ASPNETCORE_ENVIRONMENT being set to Development anywhere in the solution. However, somehow, the environment variable is still being set with that value.
What could be going wrong? I want that variable to change. Once working, what I really want to do is to add a connection string secret to environment variables so that it can be used locally via the appsettings.json file or via a docker secret environment variable if the aspnetcore web app is running in a container. I think I've got this code working, it's just that the variables are not being deployed as expected to the running container.
My VS version is:
thanks
Mmm - seems there is a problem with DockerFile support in VS. However, when I use the Orchestration Support, using docker-compose, the functionality works as expected, so I'm answering the question myself :-)

Environment variables vue js, azure kubernetes service, docker containers

I am trying to use an environment variable in a Vue.js project to store the base URL of the API used by the Vue.js app. I am able to set the variable and it works just fine in dev mode using dotenv package.
When I build a docker container, the Vue frontend doesn't hit the express JS API because the process.env.BASE_URL var is undefined... which is fine and expected.
When deploying to AKS I set the BASE_URL var in the deployment.yaml file. then I run interactive shell to print out the env variables of the Kubernetes node. BASE_URL is set as expected, but the front-end vue app isn't hitting the endpoint. If I hard-code the URL into the Vue project, it works as expected, but it is not working when using the process.env.BASE_URL
I don't really know how to debug this problem and I am out of ideas. If anyone can help I will be grateful.

Deploying web services with different environment variables in the frontend

I have a web service which consists of a backend and a forntend, and in the frontend I use an API uri which can change depending on the environment the service is being deployed to.
Using webpack's EnvironmentPlugin I can build the source code simply with other environment variables. The plugin allows me to use process.env in javascript which is convenient in the development phase but after bundling the frontend's code process.env will remain the same with the given environment variables when bundled.
The issue is that on the CI pipelines I build a docker image for the web service but I don't know the API uri until deploying it later on.
How can I effectively change the API uri based on environment variables?
You have two options for passing environment variables one is via a file
docker run --env-file ./env.list ubuntu bash
The other is via the command line with the -e option to the docker run command. you can stack the -e option to pass more than one environment variable.
one of the things you have in your dockerfile is the ability to declare the entry item. with that you can do something like:
set environment data via the docker run cmdline (via info above)
in the script get the environment info
finally, use it in the script to modify whatever file contains the uri data using something like sed

Resources