Closed maxceem closed 3 years ago
Recreation of containers is not needed after this fix, just run npm run services:up
Hi @eisbilir
so far I've merged you PR and it works, but I'm still thinking on how to avoid creating the second config file.
There is a couple of ideas.
1.
We can supply .env file to the docker-compose like this "services:up": "docker-compose -f ./local/docker-compose.yml --env-file .env up -d"
see documentation https://docs.docker.com/compose/environment-variables/#the-env-file.
It looks like we can use these variables inside the docker-compose file like this ${AUTH_URL}
and then pass to container like this:
taas-es-processor:
environment:
- KAFKA_URL=kafka:9093
- ES_HOST=http://elasticsearch:9200
- AUTH0_URL="${AUTH0_URL}"
- AUTH0_AUDIENCE="${AUTH0_AUDIENCE}"
- AUTH0_CLIENT_ID="${AUTH0_CLIENT_ID}"
- AUTH0_CLIENT_SECRET="${AUTH0_CLIENT_SECRET}"
- AUTH0_PROXY_SERVER_URL="${AUTH0_PROXY_SERVER_URL}"
2.
Another idea. Add to the NPM command services:up
additional command which would populate env values from file to the system, but only during this command run. For example using https://www.npmjs.com/package/env-cmd or something similar, like this:
"services:up": "env-cmd docker-compose -f ./local/docker-compose.yml up -d",
which suppose to populate env variable during docker-compose run, and then in the docker-compose file do like:
taas-es-processor:
environment:
- KAFKA_URL=kafka:9093
- ES_HOST=http://elasticsearch:9200
- AUTH0_URL
- AUTH0_AUDIENCE
- AUTH0_CLIENT_ID
- AUTH0_CLIENT_SECRET
- AUTH0_PROXY_SERVER_URL
Do you think something like this could work?
The main aim:
.env
file to the es processor, Good solutions, let me try both
@maxceem
Challenge https://www.topcoder.com/challenges/a769e0af-9944-4e8d-ba6f-4ed7c26e00db has been created for this ticket.This is an automated message for maxceem via Topcoder X
Challenge https://www.topcoder.com/challenges/a769e0af-9944-4e8d-ba6f-4ed7c26e00db has been assigned to eisbilir.This is an automated message for maxceem via Topcoder X
This issue only to improves the local setup process. It cannot be QAed, so I'm closing it.
Payment task has been updated: https://www.topcoder.com/challenges/a769e0af-9944-4e8d-ba6f-4ed7c26e00db
Payments Complete
Winner: eisbilir
Copilot: maxceem
Challenge a769e0af-9944-4e8d-ba6f-4ed7c26e00db
has been paid and closed.This is an automated message for maxceem via Topcoder X
During local testing I've noticed that there is an error happens in ES Processor which doesn't happen on DEV or PROD.
When I create a new Resource Booking the corresponding Work Periods are created automatically. It could happen that Kafka Event about created Work Period comes earlier than event about create Resource Booking. In such cases we retry creating Work Period in ES after some time as per https://github.com/topcoder-platform/taas-apis/issues/296#issuecomment-853352093
But it looks like when ES Processor tries to send retry Kafka Event there is an error happens
UnhandledPromiseRejectionWarning: Error: "AUTH0_URL" is required
See error log below:
It looks like ES Processor doesn't get
AUTH0_URL
environment variable even though I have.env
file that have it:I've tried to fix it by changing the
docker-compose.yaml
(addedAUTH0_*
variables) but it didn't helpI've also tried to recreate containers by
We have to find a way on how to fix this issue, or how to correctly recreate containers so that this issue is fixed.