Page MenuHomePhabricator

services: Use .env file for docker-compose
ClosedPublic

Authored by jim on Feb 16 2022, 12:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 23, 11:25 AM
Unknown Object (File)
Fri, Nov 15, 8:58 AM
Unknown Object (File)
Fri, Nov 15, 8:58 AM
Unknown Object (File)
Tue, Nov 5, 4:17 PM
Unknown Object (File)
Oct 13 2024, 11:55 AM
Unknown Object (File)
Oct 13 2024, 11:55 AM
Unknown Object (File)
Oct 13 2024, 11:54 AM
Unknown Object (File)
Oct 13 2024, 11:50 AM

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I checked and it works.

How does this work? Does docker-compose automatically sources .env file? Looks like it but correct me if I'm wrong. This is cool, I didn't know about this!

Passing back to your queue to get answers but the idea looks great!

services/scripts/run_server_image.sh
38 ↗(On Diff #9750)

Why exactly do we resign from this information? This is the only one place where we get informed in the console on which port the service's going to be run.

This revision now requires changes to proceed.Feb 18 2022, 6:29 AM

Yes, it doesn't actually source into environment variables but parses it as a file. So if you actually set the environment variables, they will override whatever is in the file. And for different configurations you can pass the --env-file flag explicitly. See https://docs.docker.com/compose/env-file/.

services/scripts/run_server_image.sh
38 ↗(On Diff #9750)

I didn't think it was a big deal as you can query the port mapping with docker-compose port (this actually seems to not work but hopefully they fix the bug in a future docker-compose release), docker port, docker ps, docker-compose config or however you choose. And part of what I'm trying to do is move away from ad-hoc scripts for executing stuff and configure docker-compose so that it can be called directly.

But if you like seeing the port map in the script, we could do something like

docker-compose up $SERVICE-server &
echo "Running $SERVICE service with port mappings:"
docker-compose port $SERVICE-server
fg %1

which prints

Running tunnelbroker service with port mappings:
50051/tcp -> 0.0.0.0:50051
50051/tcp -> :::50051

Overall great idea. Accepting this.

@jimpo, when responding to "Request changes" you should select "Re-request review" from the dropdown at the bottom. That way the diff goes to your reviewer's queue again, instead of being stuck on your queue. (This is why the status of the diff is currently "Needs Revision".)

services/scripts/run_server_image.sh
38 ↗(On Diff #9750)

(@karol-bisztyga, it looks like the only open question for you is whether you think @jimpo should add the lines above to print the port mapping)

Yes, waiting for response from @karol-bisztyga

This revision is now accepted and ready to land.Feb 25 2022, 12:27 AM
This revision now requires review to proceed.Feb 25 2022, 12:27 AM
This revision is now accepted and ready to land.Feb 25 2022, 12:38 PM