Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-compose: explicitly define COMPOSE_PROJECT_NAME #75

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ggilmore
Copy link
Contributor

@ggilmore ggilmore commented Feb 14, 2020

COMPOSE_PROJECT_NAME defines a namespace that docker-compose prefixes all networks, containers, and volumes with. This environment variable wasn't previously set, in which case docker-compose defaults COMPOSE_PROJECT_NAME to the basename of the folder that contains the docker-compose.yaml file (literally docker-compose in our case).

Not defining this variable has worked up until now, but docker-compose will treat all resources defined in docker-compose.yaml as brand new if the folder contains docker-compose.yaml was ever renamed. All the data from the old volumes will have to be manually moved over. Defining this environment variable (and making sure all docker-compose commands are run relative to this file) will prevent this from happening.

I debated between two values for COMPOSE_PROJECT_NAME:

  • docker-compose
  • sourcegraph-docker-compose.

docker-compose should allow our existing users to upgrade without any manual migrations, but it's more ambiguous than sourcegraph-docker-compose. We could choose to set COMPOSE_PROJECT_NAME=sourcegraph-docker-compose, but we'll need to figure out a migration path for our existing users (dump the PostgreSQL database?) .

[COMPOSE_PROJECT_NAME](https://docs.docker.com/compose/reference/envvars/#compose_project_name) defines a namespace that docker-compose prefixes all networks, containers, and volumes with. This previously wasn't set, in which case `docker-compose` defaults `COMPOSE_PROJECT_NAME` to the `basename` of the folder that contains the `docker-compose.yaml` file (literally `docker-compose` in our case). 

Not defining this variable has worked up until now, but docker-compose will treat all resources defined in `docker-compose.yaml` as brand new if the folder contains `docker-compose.yam` was ever renamed. All the data from the old volumes will have to be manually moved over. Defining this environment variable (and making sure all docker-compose commands are run relative to this file) will prevent this from happening. 

I debated between two values for COMPOSE_PROJECT_NAME: `docker-compose` and `sourcegraph-docker-compose`. `docker-compose` should allow our existing users to upgrade without any manual migrations, but it's more ambiguous than `sourcegraph-docker-compose`. We could choose to set `COMPOSE_PROJECT_NAME=sourcegraph-docker-compose`, but we'll need to figure out a migration path for our existing users (dump the postgres database?) .
@ggilmore
Copy link
Contributor Author

cc @slimsag PTAL and weigh in

@slimsag
Copy link
Member

slimsag commented Feb 28, 2020

docker-compose should allow our existing users to upgrade without any manual migrations, but it's more ambiguous than sourcegraph-docker-compose

I think that docker-compose is fine for almost all deployments because in most cases Soucegraph is being deployed on a VM without any other Docker resources, i.e. "we own the machine" If it's not OK on someone's machine, they could also change it.

If we start trying to suggest the docker-compose method over the server method for dev laptop deployments, we would want to do something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants