Skip to content

Commit

Permalink
Adapt justfiles for Docker Compose command (#1153)
Browse files Browse the repository at this point in the history
This should solve #1149. See also [my comment there for the
approach](#11). In short
through a variable that is substituted. Note that this may not work if
an older Docker version is installed without the Python `docker-compose`
script...As both variants will not be present. Maybe add an extra
test+warning msg for that case.

```
dockercompose := `if docker-compose --version &> /dev/null; then echo "docker-compose"; else echo "docker compose"; fi`
.
.
up:
   {{ dockercompose }} up

up-build:
    {{ dockercompose }} up --build
.
.
```

---------

Co-authored-by: Lucas <zhangyijunmetro@hotmail.com>
  • Loading branch information
justb4 and sharkAndshark committed Jan 29, 2024
1 parent e540d46 commit a864b99
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
14 changes: 8 additions & 6 deletions demo/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@

set shell := ["bash", "-c"]

dockercompose := `if docker-compose --version &> /dev/null; then echo "docker-compose"; else echo "docker compose"; fi`

@_default:
just --list --unsorted

clean:
rm -rf frontend/node_modules

up:
docker-compose up
{{ dockercompose }} up

up-build:
docker-compose up --build
{{ dockercompose }} up --build

build:
docker-compose build
{{ dockercompose }} build

up-backend:
docker-compose up db tiles --detach
{{ dockercompose }} up db tiles --detach

frontend *ARGS:
docker-compose up frontend {{ ARGS }}
{{ dockercompose }} up frontend {{ ARGS }}

[no-exit-message]
frontend-sh:
docker-compose run --interactive --entrypoint sh frontend
{{ dockercompose }} run --interactive --entrypoint sh frontend
10 changes: 6 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export CARGO_TERM_COLOR := "always"
#export RUST_LOG := "sqlx::query=info,trace"
#export RUST_BACKTRACE := "1"

dockercompose := `if docker-compose --version &> /dev/null; then echo "docker-compose"; else echo "docker compose"; fi`

@_default:
{{ just_executable() }} --list --unsorted

Expand Down Expand Up @@ -71,12 +73,12 @@ start-legacy: (docker-up "db-legacy") docker-is-ready
# Start a specific test database, e.g. db or db-legacy
[private]
docker-up name: start-pmtiles-server
docker-compose up -d {{ name }}
{{ dockercompose }} up -d {{ name }}

# Wait for the test database to be ready
[private]
docker-is-ready:
docker-compose run -T --rm db-is-ready
{{ dockercompose }} run -T --rm db-is-ready

alias _down := stop
alias _stop-db := stop
Expand All @@ -89,11 +91,11 @@ restart:

# Stop the test database
stop:
docker-compose down --remove-orphans
{{ dockercompose }} down --remove-orphans

# Start test server for testing HTTP pmtiles
start-pmtiles-server:
docker-compose up -d fileserver
{{ dockercompose }} up -d fileserver

# Run benchmark tests
bench:
Expand Down

0 comments on commit a864b99

Please sign in to comment.