Skip to content

Commit 32865ac

Browse files
authored
MCLOUD-6008: Include ssh client to make use of ssh-agent forwarding for composer (#215)
1 parent a90fd5d commit 32865ac

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

dist/bin/magento-docker

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,15 @@ case "$1" in
8585
php)
8686
version="$2"
8787
shift 2
88-
docker run --rm -it -e "MAGENTO_ROOT=/app" -v "$(pwd)":/app -v ~/.composer/cache:/root/.composer/cache "magento/magento-cloud-docker-php:${version}-cli" "$@"
88+
# allow ssh-agent forwarding for composer.json files that need access to private repos
89+
if [[ $(uname) = Darwin ]]; then
90+
# https://docs.docker.com/docker-for-mac/osxfs/#ssh-agent-forwarding (D4M > 2.2)
91+
export SSH_AUTH_SOCK="/run/host-services/ssh-auth.sock"
92+
fi
93+
docker run --rm -it -e "MAGENTO_ROOT=/app" -v "$(pwd)":/app -v ~/.composer/cache:/root/.composer/cache \
94+
--mount "type=bind,src=$HOME/.ssh/known_hosts,target=/root/.ssh/known_hosts" \
95+
--mount "type=bind,src=$SSH_AUTH_SOCK,target=$SSH_AUTH_SOCK" -e SSH_AUTH_SOCK="$SSH_AUTH_SOCK" \
96+
"magento/magento-cloud-docker-php:${version}-cli-1.1" "$@"
8997
;;
9098
*)
9199
printf "$USAGE"

images/php/7.2-cli/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ RUN apt-get update \
3434
sudo \
3535
unzip \
3636
vim \
37+
openssh-client \
3738
libbz2-dev \
3839
libjpeg62-turbo-dev \
3940
libpng-dev \

images/php/7.3-cli/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ RUN apt-get update \
3434
sudo \
3535
unzip \
3636
vim \
37+
openssh-client \
3738
libbz2-dev \
3839
libjpeg62-turbo-dev \
3940
libpng-dev \

images/php/7.4-cli/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ RUN apt-get update \
3434
sudo \
3535
unzip \
3636
vim \
37+
openssh-client \
3738
libbz2-dev \
3839
libjpeg62-turbo-dev \
3940
libpng-dev \

src/Command/Image/GeneratePhp.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class GeneratePhp extends Command
5353
'sudo',
5454
'unzip',
5555
'vim',
56+
'openssh-client',
5657
];
5758

5859
private const PHP_EXTENSIONS_ENABLED_BY_DEFAULT = [

0 commit comments

Comments
 (0)