Page MenuHomePhabricator

services: Use .env file for docker-compose
ClosedPublic

Authored by jim on Feb 16 2022, 12:09 PM.
Tags
None
Referenced Files
F2900543: D3233.id9940.diff
Sat, Oct 5, 10:41 AM
F2899836: D3233.diff
Sat, Oct 5, 8:20 AM
Unknown Object (File)
Thu, Oct 3, 8:40 AM
Unknown Object (File)
Sun, Sep 29, 1:11 AM
Unknown Object (File)
Thu, Sep 19, 10:28 PM
Unknown Object (File)
Sun, Sep 15, 10:05 AM
Unknown Object (File)
Sun, Sep 15, 10:05 AM
Unknown Object (File)
Sun, Sep 15, 10:02 AM

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

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

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

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

(@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