Skip to content

Commit 514b7da

Browse files
milasmumoshu
andauthored
Install Docker Compose v2 as a Docker CLI plugin (actions#2326)
Co-authored-by: Yusuke Kuoka <[email protected]>
1 parent c8e3bb5 commit 514b7da

7 files changed

+47
-13
lines changed

runner/actions-runner-dind-rootless.ubuntu-20.04.dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,12 @@ RUN export SKIP_IPTABLES=1 \
139139
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
140140
&& if [ "$ARCH" = "arm64" ]; then export ARCH=aarch64 ; fi \
141141
&& if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x86_64 ; fi \
142-
&& curl -fLo /home/runner/bin/docker-compose https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH} \
143-
&& chmod +x /home/runner/bin/docker-compose
142+
&& mkdir -p /home/runner/.docker/cli-plugins \
143+
&& curl -fLo /home/runner/.docker/cli-plugins/docker-compose https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH} \
144+
&& chmod +x /home/runner/.docker/cli-plugins/docker-compose \
145+
&& ln -s /home/runner/.docker/cli-plugins/docker-compose /home/runner/bin/docker-compose \
146+
&& which docker-compose \
147+
&& docker compose version
144148

145149
ENTRYPOINT ["/bin/bash", "-c"]
146150
CMD ["entrypoint-dind-rootless.sh"]

runner/actions-runner-dind-rootless.ubuntu-22.04.dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,12 @@ RUN export SKIP_IPTABLES=1 \
116116
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
117117
&& if [ "$ARCH" = "arm64" ]; then export ARCH=aarch64 ; fi \
118118
&& if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x86_64 ; fi \
119-
&& mkdir -p /home/runner/bin \
120-
&& curl -fLo /home/runner/bin/docker-compose https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-Linux-${ARCH} \
121-
&& chmod +x /home/runner/bin/docker-compose
119+
&& mkdir -p /home/runner/.docker/cli-plugins \
120+
&& curl -fLo /home/runner/.docker/cli-plugins/docker-compose https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH} \
121+
&& chmod +x /home/runner/.docker/cli-plugins/docker-compose \
122+
&& ln -s /home/runner/.docker/cli-plugins/docker-compose /home/runner/bin/docker-compose \
123+
&& which docker-compose \
124+
&& docker compose version
122125

123126
ENTRYPOINT ["/bin/bash", "-c"]
124127
CMD ["entrypoint-dind-rootless.sh"]

runner/actions-runner-dind.ubuntu-20.04.dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,12 @@ RUN set -vx; \
106106
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
107107
&& if [ "$ARCH" = "arm64" ]; then export ARCH=aarch64 ; fi \
108108
&& if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x86_64 ; fi \
109-
&& curl -fLo /usr/bin/docker-compose https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH} \
110-
&& chmod +x /usr/bin/docker-compose
109+
&& mkdir -p /usr/libexec/docker/cli-plugins \
110+
&& curl -fLo /usr/libexec/docker/cli-plugins/docker-compose https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH} \
111+
&& chmod +x /usr/libexec/docker/cli-plugins/docker-compose \
112+
&& ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/bin/docker-compose \
113+
&& which docker-compose \
114+
&& docker compose version
111115

112116
# We place the scripts in `/usr/bin` so that users who extend this image can
113117
# override them with scripts of the same name placed in `/usr/local/bin`.

runner/actions-runner-dind.ubuntu-22.04.dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,12 @@ RUN set -vx; \
8282
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
8383
&& if [ "$ARCH" = "arm64" ]; then export ARCH=aarch64 ; fi \
8484
&& if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x86_64 ; fi \
85-
&& curl -fLo /usr/bin/docker-compose https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH} \
86-
&& chmod +x /usr/bin/docker-compose
85+
&& mkdir -p /usr/libexec/docker/cli-plugins \
86+
&& curl -fLo /usr/libexec/docker/cli-plugins/docker-compose https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH} \
87+
&& chmod +x /usr/libexec/docker/cli-plugins/docker-compose \
88+
&& ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/bin/docker-compose \
89+
&& which docker-compose \
90+
&& docker compose version
8791

8892
# We place the scripts in `/usr/bin` so that users who extend this image can
8993
# override them with scripts of the same name placed in `/usr/local/bin`.

runner/actions-runner.ubuntu-20.04.dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,12 @@ RUN set -vx; \
103103
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
104104
&& if [ "$ARCH" = "arm64" ]; then export ARCH=aarch64 ; fi \
105105
&& if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x86_64 ; fi \
106-
&& curl -fLo /usr/bin/docker-compose https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH} \
107-
&& chmod +x /usr/bin/docker-compose
106+
&& mkdir -p /usr/libexec/docker/cli-plugins \
107+
&& curl -fLo /usr/libexec/docker/cli-plugins/docker-compose https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH} \
108+
&& chmod +x /usr/libexec/docker/cli-plugins/docker-compose \
109+
&& ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/bin/docker-compose \
110+
&& which docker-compose \
111+
&& docker compose version
108112

109113
# We place the scripts in `/usr/bin` so that users who extend this image can
110114
# override them with scripts of the same name placed in `/usr/local/bin`.

runner/actions-runner.ubuntu-22.04.dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,12 @@ RUN set -vx; \
8080
RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \
8181
&& if [ "$ARCH" = "arm64" ]; then export ARCH=aarch64 ; fi \
8282
&& if [ "$ARCH" = "amd64" ] || [ "$ARCH" = "i386" ]; then export ARCH=x86_64 ; fi \
83-
&& curl -fLo /usr/bin/docker-compose https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH} \
84-
&& chmod +x /usr/bin/docker-compose
83+
&& mkdir -p /usr/libexec/docker/cli-plugins \
84+
&& curl -fLo /usr/libexec/docker/cli-plugins/docker-compose https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-${ARCH} \
85+
&& chmod +x /usr/libexec/docker/cli-plugins/docker-compose \
86+
&& ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/bin/docker-compose \
87+
&& which docker-compose \
88+
&& docker compose version
8589

8690
# We place the scripts in `/usr/bin` so that users who extend this image can
8791
# override them with scripts of the same name placed in `/usr/local/bin`.

test/e2e/e2e_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,17 @@ func installActionsWorkflow(t *testing.T, testName, runnerLabel, testResultCMNam
10811081
},
10821082
},
10831083
)
1084+
1085+
// Ensure both the alias and the full command work after
1086+
// https://github.com/actions/actions-runner-controller/pull/2326
1087+
steps = append(steps,
1088+
testing.Step{
1089+
Run: "docker-compose version",
1090+
},
1091+
testing.Step{
1092+
Run: "docker compose version",
1093+
},
1094+
)
10841095
}
10851096

10861097
steps = append(steps,

0 commit comments

Comments
 (0)