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

Handle docker compose and docker space compose #85

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
11 changes: 11 additions & 0 deletions docker/base.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

DOCKER_COMPOSE_BIN="docker-compose"
DOCKER_COMPOSE_FROM_DOCKER="docker compose"
DOCKER_COMPOSE=""
Copy link
Owner

Choose a reason for hiding this comment

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

instead of storing a variable, what you think about echoing the value?

Copy link
Contributor Author

@vandaimer vandaimer Apr 18, 2023

Choose a reason for hiding this comment

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

First, to be honest, not sure if is really needed this line 5, I could remove that.


Second, I can do this here base.sh

if [ -x "$(command -v $DOCKER_COMPOSE_BIN)" ]; then
  echo $DOCKER_COMPOSE_BIN
else
  echo $DOCKER_COMPOSE_FROM_DOCKER
fi

And on down.sh and run.sh

DOCKER_COMPOSE=$("$ROOT/docker/base.sh")

Works!


My concern with this change is that the file's name is base, and the idea is to add/move more things into it, for example, $ROOT/docker/dockerfile that has been repeated many times, but the value is the same for all usages.

So, to return (echoing) more than one value from base would be difficult from the file reading the returns or I just don't know how to do it.

So, let me know what is your idea and let's make that happen :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I echo the value instead assigned into a variable, then?

Copy link
Owner

Choose a reason for hiding this comment

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

Still did not have time to review this one yet 😬

Once I review I will answer you!


if [ -x "$(command -v $DOCKER_COMPOSE_BIN)" ]; then
DOCKER_COMPOSE=$DOCKER_COMPOSE_BIN
else
DOCKER_COMPOSE=$DOCKER_COMPOSE_FROM_DOCKER
fi
3 changes: 2 additions & 1 deletion docker/down.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

ROOT="$(dirname $( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P ))"
$ROOT/docker/env.sh
. $ROOT/docker/base.sh
Copy link
Owner

Choose a reason for hiding this comment

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

it is needed to run with .? (same as source, right?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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


docker-compose \
$DOCKER_COMPOSE \
--file $ROOT/docker/docker-compose.yaml \
--project-directory $ROOT \
down --volumes --rmi 'all'
3 changes: 2 additions & 1 deletion docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

ROOT="$(dirname $( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P ))"
$ROOT/docker/env.sh
. $ROOT/docker/base.sh

docker-compose \
$DOCKER_COMPOSE \
--file $ROOT/docker/docker-compose.yaml \
--project-directory $ROOT \
run --rm cly $@