Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions cmd/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,27 @@ register 'compose' 'ps' 'list containers' compose_ps
function compose_top(){ compose_exec top $@; }
register 'compose' 'top' 'display the running processes of a container' compose_top

# the 'docker compose' subcommand is now the recommended method of calling compose.
# if not available, we fallback to the legacy 'docker-compose' command.
function compose_exec(){
# check whether there is a local compose file and append them to the global one.
composeFilePath="-f ../../docker-compose.yml -f ./docker-compose.yml"
export peliasRegion="projects/$(basename $(pwd))"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the peliasRegion variable used for?

My understanding is as long as we require people to cd projects/someProject, we don't need to consider this relative path anywhere. Am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this variable to properly mount the directories into the docker container. E.g.

- "./${peliasRegion}/pelias.json:/code/pelias.json"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna play with this a bit, I feel like there's got to be a way to remove it, right?

I find it really surprising that docker would base the mount directories from where the docker-compose.yml file is located rather than the current working directory where the docker compose command is run from.

Let me know if you've played around with it more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, looks like they do use the path relative to docker-compose.yml, which is annoying, but presumably they have their reasons 😆

I've made a few changes so will likely open my own PR so we can iterate more quickly on this.

if [ ! -f docker-compose.yml ];then
echo "No local file. Using only global compose file."
composeFilePath="-f ../../docker-compose.yml"
fi

# the 'docker compose' subcommand is now the recommended method of calling compose.
# if not available, we fallback to the legacy 'docker-compose' command.
NATIVE_COMPOSE_VERSION=$(docker compose version 2> /dev/null || true)
if [ -z "$NATIVE_COMPOSE_VERSION" ]; then
docker-compose $@;
dockerComposeCommand="docker-compose"
else
docker compose $@;
dockerComposeCommand="docker compose"
fi

# execute the command with the compose file(s) and any additional arguments
$dockerComposeCommand $composeFilePath $@;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not that happy with the solution, since it's not very readable. However, it's the best way I could think of to avoid some code duplication.

unset $peliasRegion
}
register 'compose' 'exec' 'execute an arbitrary `docker compose` command' compose_exec

Expand All @@ -40,4 +52,3 @@ register 'compose' 'kill' 'kill one or more `docker compose` service(s)' compose

function compose_down(){ compose_exec down; }
register 'compose' 'down' 'stop all `docker compose` service(s)' compose_down

62 changes: 31 additions & 31 deletions projects/australia/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
container_name: pelias_schema
user: "${DOCKER_USER}"
volumes:
- "./pelias.json:/code/pelias.json"
- "./${peliasRegion}/pelias.json:/code/pelias.json"
api:
image: pelias/api:master
container_name: pelias_api
Expand All @@ -23,7 +23,7 @@ services:
environment: [ "PORT=4000" ]
ports: [ "0.0.0.0:4000:4000" ]
volumes:
- "./pelias.json:/code/pelias.json"
- "./${peliasRegion}/pelias.json:/code/pelias.json"
placeholder:
image: pelias/placeholder:master
container_name: pelias_placeholder
Expand All @@ -32,63 +32,63 @@ services:
environment: [ "PORT=4100" ]
ports: [ "127.0.0.1:4100:4100" ]
volumes:
- "./pelias.json:/code/pelias.json"
- "${DATA_DIR}:/data"
- "./blacklist/:/data/blacklist"
- "./${peliasRegion}/pelias.json:/code/pelias.json"
- "./${peliasRegion}/${DATA_DIR}:/data"
- "./${peliasRegion}/blacklist/:/data/blacklist"
whosonfirst:
image: pelias/whosonfirst:master
container_name: pelias_whosonfirst
user: "${DOCKER_USER}"
volumes:
- "./pelias.json:/code/pelias.json"
- "${DATA_DIR}:/data"
- "./blacklist/:/data/blacklist"
- "./${peliasRegion}/pelias.json:/code/pelias.json"
- "./${peliasRegion}/${DATA_DIR}:/data"
- "./${peliasRegion}/blacklist/:/data/blacklist"
openstreetmap:
image: pelias/openstreetmap:master
container_name: pelias_openstreetmap
user: "${DOCKER_USER}"
volumes:
- "./pelias.json:/code/pelias.json"
- "${DATA_DIR}:/data"
- "./blacklist/:/data/blacklist"
- "./${peliasRegion}/pelias.json:/code/pelias.json"
- "./${peliasRegion}/${DATA_DIR}:/data"
- "../${peliasRegion}/blacklist/:/data/blacklist"
openaddresses:
image: pelias/openaddresses:master
container_name: pelias_openaddresses
user: "${DOCKER_USER}"
volumes:
- "./pelias.json:/code/pelias.json"
- "${DATA_DIR}:/data"
- "./blacklist/:/data/blacklist"
- "./${peliasRegion}/pelias.json:/code/pelias.json"
- "./${peliasRegion}/${DATA_DIR}:/data"
- "./${peliasRegion}/blacklist/:/data/blacklist"
geonames:
image: pelias/geonames:master
container_name: pelias_geonames
user: "${DOCKER_USER}"
volumes:
- "./pelias.json:/code/pelias.json"
- "${DATA_DIR}:/data"
- "./blacklist/:/data/blacklist"
- "./${peliasRegion}/pelias.json:/code/pelias.json"
- "./${peliasRegion}/${DATA_DIR}:/data"
- "./${peliasRegion}/blacklist/:/data/blacklist"
transit:
image: pelias/transit:master
container_name: pelias_transit
user: "${DOCKER_USER}"
volumes:
- "./pelias.json:/code/pelias.json"
- "${DATA_DIR}:/data"
- "./${peliasRegion}/pelias.json:/code/pelias.json"
- "./${peliasRegion}/${DATA_DIR}:/data"
csv-importer:
image: pelias/csv-importer:master
container_name: pelias_csv_importer
user: "${DOCKER_USER}"
volumes:
- "./pelias.json:/code/pelias.json"
- "${DATA_DIR}:/data"
- "./blacklist/:/data/blacklist"
- "./${peliasRegion}/pelias.json:/code/pelias.json"
- "./${peliasRegion}/${DATA_DIR}:/data"
- "./${peliasRegion}/blacklist/:/data/blacklist"
polylines:
image: pelias/polylines:master
container_name: pelias_polylines
user: "${DOCKER_USER}"
volumes:
- "./pelias.json:/code/pelias.json"
- "${DATA_DIR}:/data"
- "./${peliasRegion}/pelias.json:/code/pelias.json"
- "./${peliasRegion}/${DATA_DIR}:/data"
interpolation:
image: pelias/interpolation:master
container_name: pelias_interpolation
Expand All @@ -97,8 +97,8 @@ services:
environment: [ "PORT=4300" ]
ports: [ "127.0.0.1:4300:4300" ]
volumes:
- "./pelias.json:/code/pelias.json"
- "${DATA_DIR}:/data"
- "./${peliasRegion}/pelias.json:/code/pelias.json"
- "./${peliasRegion}/${DATA_DIR}:/data"
pip:
image: pelias/pip-service:master
container_name: pelias_pip-service
Expand All @@ -107,16 +107,16 @@ services:
environment: [ "PORT=4200" ]
ports: [ "127.0.0.1:4200:4200" ]
volumes:
- "./pelias.json:/code/pelias.json"
- "${DATA_DIR}:/data"
- "./${peliasRegion}/pelias.json:/code/pelias.json"
- "./${peliasRegion}/${DATA_DIR}:/data"
elasticsearch:
image: pelias/elasticsearch:7.17.27
container_name: pelias_elasticsearch
user: "${DOCKER_USER}"
restart: always
ports: [ "127.0.0.1:9200:9200", "127.0.0.1:9300:9300" ]
volumes:
- "${DATA_DIR}/elasticsearch:/usr/share/elasticsearch/data"
- "./${peliasRegion}/${DATA_DIR}/elasticsearch:/usr/share/elasticsearch/data"
ulimits:
memlock:
soft: -1
Expand All @@ -132,5 +132,5 @@ services:
restart: "no"
command: "--help"
volumes:
- "./pelias.json:/code/pelias.json"
- "./test_cases:/code/pelias/fuzzy-tester/test_cases"
- "./${peliasRegion}/pelias.json:/code/pelias.json"
- "./${peliasRegion}/test_cases:/code/pelias/fuzzy-tester/test_cases"
112 changes: 0 additions & 112 deletions projects/austria/docker-compose.yml

This file was deleted.

Loading