diff --git a/container/README.md b/container/README.md index 6be3f59..14dc228 100644 --- a/container/README.md +++ b/container/README.md @@ -9,3 +9,12 @@ If the project directory is owned by `root` then files will be written out as `r Credit goes to https://github.com/graze/docker-composer/blob/master/php-7.0/composer-wrapper * Loop over each argument and append the argument if the command matches one we need to use `--ignore-platform-reqs` with. Found using the following search: https://github.com/composer/composer/search?q=ignore-platform-reqs+path%3Asrc%2FComposer%2FCommand%2F Uses `set` to update the arguments, see https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html. + +# `set-ssh-key-perms` + +Credit goes to https://nickjanetakis.com/blog/docker-tip-56-volume-mounting-ssh-keys-into-a-docker-container + +Initial use case is for users of "Docker for Windows". Due to file permission differences with the Windows OS and Linux, you need to adjust them inside the container before use. + +* Copy the ssh keys mounted to `/tmp/` to `/home/dev/` and `/root/`. Ensuring the original are not modified. +* Set permissions on `.ssh/` directories. Ensuring the permissions are correct. diff --git a/container/set-ssh-key-perms b/container/set-ssh-key-perms new file mode 100644 index 0000000..ef8b11d --- /dev/null +++ b/container/set-ssh-key-perms @@ -0,0 +1,24 @@ +#!/bin/sh +# Required for volume mounting ssh keys for "Docker for Windows" +# credit to: https://nickjanetakis.com/blog/docker-tip-56-volume-mounting-ssh-keys-into-a-docker-container +# Usage: volume mount your ssh key directory to /tmp/.ssh + +set -e + +if [ -d /tmp/.ssh ]; then + cp -R /tmp/.ssh /root/.ssh + cp -R /tmp/.ssh /home/dev/.ssh + chmod 700 /root/.ssh + chmod 700 /home/dev/.ssh + + if [ -f /tmp/.ssh/id_rsa.pub ]; then + chmod 644 /root/.ssh/id_rsa.pub + chmod 644 /home/dev/.ssh/id_rsa.pub + fi + if [ -f /tmp/.ssh/id_rsa ]; then + chmod 600 /root/.ssh/id_rsa + chmod 600 /home/dev/.ssh/id_rsa + fi +fi + +exec "$@"