You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-9Lines changed: 11 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
How to separate your credentials, secrets, and configurations from your source code with environment variables
1
+
# How to separate your credentials, secrets, and configurations from your source code with environment variables
2
2
- version: 1.0
3
3
- Last update: Aug 2021
4
4
- Environment: Windows
@@ -14,7 +14,7 @@ How should we solve this issue?
14
14
15
15
## <aid="12factor_config"></a>Store config in the environment
16
16
17
-
The [Twelve-Factor App methodology](https://12factor.net/)which is one of the most influential patterns to designing scalable software-as-a-service application. The methodology [3rd factor](https://12factor.net/config) (aka Config principle) states that configuration information should be kept as environment variables and injected into the application on runtime as the following quotes:
17
+
The [Twelve-Factor App methodology](https://12factor.net/) is one of the most influential patterns to designing scalable software-as-a-service applications. The methodology [3rd factor](https://12factor.net/config) (aka Config principle) states that configuration information should be kept as environment variables and injected into the application on runtime as the following quotes:
18
18
19
19
>An app’s config is everything that is likely to vary between deploys (staging, production, developer environments, etc). This includes:
20
20
>- Resource handles to the database, Memcached, and other backing services
@@ -216,11 +216,11 @@ By default, it will use find_dotenv to search for a .env file in a current direc
216
216
217
217
## <aid="dotenv_java"></a>dotenv with Java
218
218
219
-
The next section demonstrates with the [dotenv-java](https://github.com/cdimascio/dotenv-java) library. The example Java console application uses the library to store the Refinitiv Real-Time - Optimized (RTO) credentials and configurations for the application.
219
+
The next section demonstrates the [dotenv-java](https://github.com/cdimascio/dotenv-java) library. The example Java console application uses the library to store the Refinitiv Real-Time - Optimized (RTO) credentials and configurations for the application.
220
220
221
221
### <aid="whatis_rto"></a>What is Refinitiv Real-Time - Optimized?
222
222
223
-
As part of the Refinitiv Data Platform, [Refinitiv Real-Time - Optimized](https://developers.refinitiv.com/en/api-catalog/elektron/refinitiv-websocket-api/quick-start#connecting-to-refinitiv-real-time-optimized) (formerly known as ERT in Cloud) gives you access to best in class RealTime market data delivered in the cloud. Refinitiv Real-Time - Optimized is a new delivery mechanism for RDP, using the AWS (Amazon Web Services) cloud. Once a connection to RDP is established using Refinitiv Real-Time - Optimized, data can be retrieved using [Websocket API for Pricing Streaming and Real-Time Services](https://developers.refinitiv.com/en/api-catalog/elektron/refinitiv-websocket-api) aka WebSocket API.
223
+
As part of the Refinitiv Data Platform, [Refinitiv Real-Time - Optimized](https://developers.refinitiv.com/en/api-catalog/elektron/refinitiv-websocket-api/quick-start#connecting-to-refinitiv-real-time-optimized) (formerly known as ERT in Cloud) gives you access to best in class Real-Time market data delivered in the cloud. Refinitiv Real-Time - Optimized is a new delivery mechanism for RDP, using the AWS (Amazon Web Services) cloud. Once a connection to RDP is established using Refinitiv Real-Time - Optimized, data can be retrieved using [Websocket API for Pricing Streaming and Real-Time Services](https://developers.refinitiv.com/en/api-catalog/elektron/refinitiv-websocket-api) aka WebSocket API.
224
224
225
225
For more detail regarding Refinitiv Real-Time - Optimized, please see the following APIs resources:
226
226
-[WebSocket API Quick Start](https://developers.refinitiv.com/en/api-catalog/refinitiv-real-time-opnsrc/refinitiv-websocket-api/quick-start#connecting-to-refinitiv-real-time-optimized) page.
Next, the application uses those configurations to authenticate with RDP Auth Service, get the RTO WebSocket endpoint dynamically from the Service Discovery mechanism and further connects and consume the real-time streaming data from the WebSocket server.
290
+
Next, the application uses those configurations to authenticate with the RDP Auth Service, get the RTO WebSocket endpoint dynamically from the Service Discovery mechanism and further connects and consume the real-time streaming data from the WebSocket server.
291
291
292
292
## <aid="dotenv_docker"></a>Using Environment Variables with Docker
All containers from the resulting image can access the environment variables set using Dockerfile ```ENV``` instruction, unless it is replaced by the Docker run command options.
321
321
322
-
When you run the Docker containers from the above Docker image setting, the ```system.out.println(dotenv.get("USERNAME"));``` (Java) and ```print('User: ', os.getenv('USERNAME'))``` (Python) will print the USERNAME information as *DOCKER_CONTAINER*.
322
+
When you run the Docker containers from the above Docker image setting, the ```system.out.println(dotenv.get("USERNAME"));``` (Java) and ```print('User: ', os.getenv('USERNAME'))``` (Python) will print the USERNAME information as *DOCKER_CONTAINER*.
323
323
324
324
### <aid="docker_using"></a>Environment Variables with Docker Run command
325
325
326
-
You can use the ```--env``` (```-e``` for shorter syntax) options with the Docker run command to set the environment variable of the container.
326
+
You can use the ```--env``` (```-e``` for a shorter syntax) options with the Docker run command to set the environment variable of the container. The example with the Python RDP console container is the following:
327
327
328
328
```
329
329
docker run --env <key>=<value> IMAGE
330
330
```
331
331
332
-
Please note that if you want to set multiple environment variables, you need to set ```--env```` multiple times
332
+
Please note that if you want to set multiple environment variables, you need to set ```--env``` multiple times
Alternatively, you can use the ```--env-file``` option to parse a file of environment variables (```.env``` file) to a Docker container.
@@ -356,7 +358,7 @@ docker build . -t java_rto
356
358
docker run --env-file .env --name java_websocket java_rto
357
359
```
358
360
359
-
Please note that the ```ENV``` instruction, ```--env``` and ```--env-file``` options support the normal system environment variables, you do not need to use the dotenv library with Docker.
361
+
Please note that the ```ENV``` instruction, ```--env``` and ```--env-file``` options support the normal system environment variables too. The dotenv library is not required to be used with Docker.
0 commit comments