Skip to content

Commit 4f8ca30

Browse files
Variabilize passwords as env vars to follow the best practice that passwords should not be stored in config files.
1 parent a2d499b commit 4f8ca30

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ VALKEY_ADDR=valkey-cart:${VALKEY_PORT}
173173
POSTGRES_HOST=astronomy-db
174174
POSTGRES_PORT=5432
175175
POSTGRES_PASSWORD=changeit
176+
POSTGRES_ASTRONOMY_PASSWORD=astronomy_password # defined in src/postgresql/init.sql
177+
POSTGRES_MONITORING_PASSWORD=monitoring_password # defined in src/postgresql/init.sql
176178
POSTGRES_DOCKERFILE=./src/postgresql/Dockerfile
177179

178180
# ********************

docker-compose.minimal.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ services:
425425
- OTEL_SERVICE_NAME=product-catalog
426426
- OTEL_CONFIG_FILE=/otel-config.yml
427427
- OTEL_SEMCONV_STABILITY_OPT_IN=database
428-
- DB_CONNECTION_STRING=postgres://astronomy_user:astronomy_password@${POSTGRES_HOST}/astronomy_db?sslmode=disable
428+
- DB_CONNECTION_STRING=postgres://astronomy_user:${POSTGRES_ASTRONOMY_PASSWORD}@${POSTGRES_HOST}/astronomy_db?sslmode=disable
429429
depends_on:
430430
otel-collector:
431431
condition: service_started
@@ -460,7 +460,7 @@ services:
460460
- OTEL_SERVICE_NAME=product-reviews
461461
- OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true
462462
- PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
463-
- DB_CONNECTION_STRING=host=${POSTGRES_HOST} user=astronomy_user password=astronomy_password dbname=astronomy_db
463+
- DB_CONNECTION_STRING=host=${POSTGRES_HOST} user=astronomy_user password=${POSTGRES_ASTRONOMY_PASSWORD} dbname=astronomy_db
464464
- LLM_BASE_URL
465465
- OPENAI_API_KEY
466466
- LLM_MODEL
@@ -743,6 +743,7 @@ services:
743743
- POSTGRES_HOST
744744
- POSTGRES_PORT
745745
- POSTGRES_PASSWORD
746+
- POSTGRES_MONITORING_PASSWORD
746747
- GOMEMLIMIT=160MiB
747748

748749
# Prometheus

docker-compose.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ services:
3737
- OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE
3838
- OTEL_RESOURCE_ATTRIBUTES
3939
- OTEL_SERVICE_NAME=accounting
40-
- DB_CONNECTION_STRING=Host=${POSTGRES_HOST};Username=astronomy_user;Password=astronomy_password;Database=astronomy_db
40+
- DB_CONNECTION_STRING=Host=${POSTGRES_HOST};Username=astronomy_user;Password=${POSTGRES_ASTRONOMY_PASSWORD};Database=astronomy_db
4141
- OTEL_DOTNET_AUTO_TRACES_ENTITYFRAMEWORKCORE_INSTRUMENTATION_ENABLED=false
4242
depends_on:
4343
otel-collector:
@@ -504,7 +504,7 @@ services:
504504
- OTEL_SERVICE_NAME=product-catalog
505505
- OTEL_CONFIG_FILE=/otel-config.yml
506506
- OTEL_SEMCONV_STABILITY_OPT_IN=database
507-
- DB_CONNECTION_STRING=postgres://astronomy_user:astronomy_password@${POSTGRES_HOST}/astronomy_db?sslmode=disable
507+
- DB_CONNECTION_STRING=postgres://astronomy_user:${POSTGRES_ASTRONOMY_PASSWORD}@${POSTGRES_HOST}/astronomy_db?sslmode=disable
508508
depends_on:
509509
otel-collector:
510510
condition: service_started
@@ -541,7 +541,7 @@ services:
541541
- OTEL_SERVICE_NAME=product-reviews
542542
- OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true
543543
- PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
544-
- DB_CONNECTION_STRING=host=${POSTGRES_HOST} user=astronomy_user password=astronomy_password dbname=astronomy_db
544+
- DB_CONNECTION_STRING=host=${POSTGRES_HOST} user=astronomy_user password=${POSTGRES_ASTRONOMY_PASSWORD} dbname=astronomy_db
545545
- LLM_BASE_URL
546546
- OPENAI_API_KEY
547547
- LLM_MODEL
@@ -893,6 +893,7 @@ services:
893893
- POSTGRES_HOST
894894
- POSTGRES_PORT
895895
- POSTGRES_PASSWORD
896+
- POSTGRES_MONITORING_PASSWORD
896897
- GOMEMLIMIT=160MiB
897898

898899
# Prometheus

src/otel-collector/otelcol-config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ receivers:
2525
postgresql:
2626
endpoint: ${POSTGRES_HOST}:${POSTGRES_PORT}
2727
username: monitoring_user
28-
password: monitoring_password
28+
password: ${env:POSTGRES_MONITORING_PASSWORD}
2929
metrics:
3030
postgresql.blks_hit:
3131
enabled: true

0 commit comments

Comments
 (0)