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

Upgrade to docker compose@v2 #32

Merged
merged 3 commits into from
Apr 21, 2023
Merged

Upgrade to docker compose@v2 #32

merged 3 commits into from
Apr 21, 2023

Conversation

caffeinatedpixel
Copy link
Contributor

Changes:

  • Updates check_docker.sh to check for v20.10.13 as the minimum installed version. This version introduced the inclusion of the docker-compose-plugin repo, which is the easiest way to install docker compose
  • Updates check_docker-compose.sh to check for a minimum version of 2.0 and uses the docker compose version command instead of an alias/potentially targeting docker-compose
  • Updates install_docker.sh to:
    • No longer install python3-pip
    • Attempt to uninstall the docker-compose pip package
    • Update apt/yum packages (needed after installing docker 20.10.13 )
    • Install docker-compose-plugin
    • Create an alias for docker-compose to docker compose

fi

# Create alias for docker-compose to call docker compose
echo 'docker compose "$@"' | $SUDO tee /usr/local/bin/docker-compose > /dev/null
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this will take care of overwriting/ uninstalling the native installations created on line 187 of the previous version.

Copy link
Contributor

@Zalgo2462 Zalgo2462 left a comment

Choose a reason for hiding this comment

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

We can run into a case where the docker compose plugin and the old docker-compose script are both installed. In this case, we need to make sure to uninstall the old docker-compose script and create the alias. We will need to add a new return code in check_docker.sh for this case. I believe the existing catch in install_docker.sh for non-zero return codes will handle this appropriately.

In particular, running yum deplist docker-ce-cli shows that Centos7 will install the docker-compose plugin whenever docker is installed.

# Install docker-compose-plugin
if [ -s /etc/redhat-release ] && grep -iq 'release 7\|release 8' /etc/redhat-release ; then
# TODO: add silencing flags
$SUDO yum update
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a TODO here already marking this change, but I'm leaving a note here to track it in the PR review.

We need to pass -q -y here.

if [ ! -e /usr/bin/docker-compose ]; then
$SUDO ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
fi

$SUDO chown "$USER":"$USER" /home/"$USER"/.docker -R
Copy link
Contributor

Choose a reason for hiding this comment

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

We will need to add a mkdir -p "$HOME"/.docker before these lines.

I received the following error:
image

Also, please change /home/"$USER" to "$HOME" as, sometimes, the two are not equivalent.

@caffeinatedpixel caffeinatedpixel marked this pull request as ready for review April 20, 2023 16:41
Copy link
Contributor

@Zalgo2462 Zalgo2462 left a comment

Choose a reason for hiding this comment

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

I tested the latest changes on a raspberry pi (arm64) device which had the old docker-compose installed via pip, and I tested the changes on a centos7 (x86) device which had the old docker-compose installed as a native binary alongside the docker compose plugin. Both tests went well.

There is one cosmetic bug I noticed, but that should be a quick fix-up. Other than that, I say this is good to go.

@@ -21,6 +22,11 @@ if ! docker compose version > /dev/null 2>&1 ; then
exit 4
fi

# verify that docker compose & docker-compose aren't both installed
if docker-compose version | grep '^docker-compose .* [0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*' ; then
Copy link
Contributor

Choose a reason for hiding this comment

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

This check will print out to the cli. I believe we want to add a -q to the grep command.

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