Skip to content

Install as a Docker CLI plugin #48

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

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions pkg/docker-compose/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ func (m *Mixin) Build(ctx context.Context) error {
}

dockerfileLines := fmt.Sprintf(`RUN apt-get update && apt-get install -y curl && \
curl -fL "https://github.com/docker/compose/releases/download/v%s/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose && \
chmod +x /usr/local/bin/docker-compose`, dockerComposeVersion)
curl -fL "https://github.com/docker/compose/releases/download/v%s/docker-compose-linux-x86_64" -o /usr/local/lib/docker/cli-plugins/docker-compose --create-dirs && \
chmod +x /usr/local/lib/docker/cli-plugins/docker-compose && \
Copy link
Member

Choose a reason for hiding this comment

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

Why ln over setting it in -o, just generally curious

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has changed slightly after merging the latest from main and fixing the conflicts. Initially, I updated it to use ADD to download the file and then RUN ln -s to create the symlink (63bfacc). However, after doing that, it occurred to me that instead of creating a symlink in /usr/local/bin, we could just update the PATH:

ADD --chmod=755 https://github.com/docker/compose/releases/download/v%s/docker-compose-linux-x86_64 /usr/local/lib/docker/cli-plugins/docker-compose
ENV PATH="$PATH:/usr/local/lib/docker/cli-plugins"

This seems like a nicer way of ensuring that docker-compose can still be used. I've tested and pushed that change up, but could revert to using a symlink or just installing the binary into both folders, whichever you think is cleaner.

Thanks for the review!

ln -s /usr/local/lib/docker/cli-plugins/docker-compose /usr/local/bin/docker-compose`, dockerComposeVersion)

fmt.Fprintln(m.Out, dockerfileLines)

Expand Down
5 changes: 3 additions & 2 deletions pkg/docker-compose/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (

func TestMixin_Build(t *testing.T) {
const buildOutput = `RUN apt-get update && apt-get install -y curl && \
curl -fL "https://github.com/docker/compose/releases/download/v2.10.2/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose && \
chmod +x /usr/local/bin/docker-compose
curl -fL "https://github.com/docker/compose/releases/download/v2.10.2/docker-compose-linux-x86_64" -o /usr/local/lib/docker/cli-plugins/docker-compose --create-dirs && \
chmod +x /usr/local/lib/docker/cli-plugins/docker-compose && \
ln -s /usr/local/lib/docker/cli-plugins/docker-compose /usr/local/bin/docker-compose
`

t.Run("build", func(t *testing.T) {
Expand Down