Skip to content

Commit

Permalink
docker: Set db_name and password through .env
Browse files Browse the repository at this point in the history
  • Loading branch information
angad-k committed Feb 16, 2022
1 parent 8154bb5 commit d25c502
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PINGER_DB_PASSWORD=passwrd
PINGER_DB_NAME=pinger
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

# Default config files
/agent.yml
/.env
4 changes: 2 additions & 2 deletions deploy/pinger.apache.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Listen 80
<VirtualHost *:80>
ServerName pinger.staging.sdslabs.*
ServerAlias pinger.sdslabs.*
ServerName pinger.sdslabs.*
ServerAlias pinger.staging.sdslabs.*
# Other directives here
<Location />
ProxyPass http://127.0.0.1:9010
Expand Down
7 changes: 5 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ services:
image: timescale/timescaledb:2.0.0-pg12
# Setting environment variables for Timescale
environment:
POSTGRES_PASSWORD: "password"
POSTGRES_DB: "pinger"
POSTGRES_PASSWORD: "${PINGER_DB_PASSWORD:-password}"
POSTGRES_DB: "${PINGER_DB_NAME:-pinger}"
# Healthcheck conditions are defined since pinger service needs to know if Timescale has started
# pg_isready is a binary that is available with the postgres image(timescale is built upon postgres)
healthcheck:
Expand All @@ -24,6 +24,9 @@ services:
timescale:
condition: service_healthy
build: ./
environment:
METRICS.DB_NAME: "${PINGER_DB_NAME:-pinger}"
METRICS.PASSWORD: "${PINGER_DB_PASSWORD:-password}"
# PINGER_PORT is the port on the host machine where the service will be available. Set it through .env
ports:
- "${PINGER_PORT:-9010}:9010"
Expand Down
4 changes: 4 additions & 0 deletions docs/src/contributing/build-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ $ make docker TAG="pinger:v1.2.3"
A `docker-compose.yml` is also provided to get pinger started more easier.
Just add an `agent.yml` according to your use case and then run `docker-compose up`.
This will get both the timescale db and pinger container up and running in no time!
For setting custom values for the Timescale DB's name and password, just run `cp .env.sample .env`
and then change the values in the `.env` according to your need. The changes will reflect in both
Timescale's and Pinger's container (overriding the name and password value set in `agent.yml`) without
requiring you to make changes in multiple places.

## Documentation

Expand Down

0 comments on commit d25c502

Please sign in to comment.