Skip to content

Commit

Permalink
Added Compose V2 compatibility (#10)
Browse files Browse the repository at this point in the history
This update adds a simple check if Compose version 1 or 2 is used and adapted the wrappers to work with version 2 as well.

https://docs.docker.com/compose/
> From July 2023 Compose V1 stopped receiving updates.

Docker V1 isn't shipped, or updated anymore. 

This update was tested with
docker compose V2
docker compose V2 with docker-switch (
docker-compose V1
  • Loading branch information
quorn23 authored Oct 22, 2023
1 parent 1f70f79 commit 20aa51c
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions pullio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ DOCKER_BINARY="${DOCKER_BINARY:-$(which 'docker')}"
CACHE_LOCATION=/tmp
TAG=""
DEBUG=""
CURRENT_VERSION=0.0.4
CURRENT_VERSION=0.0.5
LATEST_VERSION=$(curl -fsSL "https://api.github.com/repos/hotio/pullio/releases" | jq -r .[0].tag_name)

if ! docker compose version >/dev/null 2>&1; then
echo "Using docker-compose V1"
COMPOSE_V2="0"
else
echo "Using docker compose V2"
COMPOSE_V2="1"
fi

while [ "$1" != "" ]; do
PARAM=$(printf "%s\n" $1 | awk -F= '{print $1}')
VALUE=$(printf "%s\n" $1 | sed 's/^[^=]*=//g')
Expand All @@ -32,22 +40,39 @@ echo "Latest version: ${LATEST_VERSION}"

compose_pull_wrapper() {
if [[ -z ${COMPOSE_BINARY} ]]; then
"${DOCKER_BINARY}" run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$1:$1" -w="$1" linuxserver/docker-compose pull "$2"
if [[ "${COMPOSE_V2}" == "1" ]]; then
"${DOCKER_BINARY}" compose pull "$2"
else
"${DOCKER_BINARY}" run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$1:$1" -w="$1" linuxserver/docker-compose pull "$2"
fi
else
cd "$1" || exit 1
"${COMPOSE_BINARY}" pull "$2"
if [[ "${COMPOSE_V2}" == "1" ]]; then
"${DOCKER_BINARY}" compose pull "$2"
else
"${COMPOSE_BINARY}" pull "$2"
fi
fi
}

compose_up_wrapper() {
if [[ -z ${COMPOSE_BINARY} ]]; then
"${DOCKER_BINARY}" run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$1:$1" -w="$1" linuxserver/docker-compose up -d --always-recreate-deps "$2"
if [[ "${COMPOSE_V2}" == "1" ]]; then
"${DOCKER_BINARY}" compose up -d --always-recreate-deps "$2"
else
"${DOCKER_BINARY}" run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$1:$1" -w="$1" linuxserver/docker-compose up -d --always-recreate-deps "$2"
fi
else
cd "$1" || exit 1
"${COMPOSE_BINARY}" up -d --always-recreate-deps "$2"
if [[ "${COMPOSE_V2}" == "1" ]]; then
"${DOCKER_BINARY}" compose up -d --always-recreate-deps "$2"
else
"${COMPOSE_BINARY}" up -d --always-recreate-deps "$2"
fi
fi
}


send_discord_notification() {
if [[ "${LATEST_VERSION}" != "${CURRENT_VERSION}" ]]; then
footer_text="Powered by Pullio (update available)"
Expand Down

0 comments on commit 20aa51c

Please sign in to comment.