From 5f033e5019a024c7846a232a9427a58b317d0e4c Mon Sep 17 00:00:00 2001 From: Andy Neff Date: Sun, 16 Aug 2015 11:18:45 -0400 Subject: [PATCH] Added DOCKER_OTHER_OPTIONS and started patching for windows --- docker/README.md | 18 +++++++++++++++--- docker/build_dockers.bsh | 7 +++---- docker/docker+.bsh | 8 +++----- docker/run_dockers.bsh | 13 ++++++++++--- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/docker/README.md b/docker/README.md index 53a0d81a..ef1c37e6 100644 --- a/docker/README.md +++ b/docker/README.md @@ -27,12 +27,17 @@ dependencies) ./docker/test_dockers.bsh -##Using the Dockers## +## Using the Dockers ## All docker commands need to either be run as root **or** as a user with docker permissions. Adding your user name to the docker group (or setting up boot2docker environment) is probably the easiest. +For Mac and Windows users, the git-lfs repo needs to be in your Users directory +or else boot2docker magic won't work. Alternatively, you could add addition +mount points like +[this](http://stackoverflow.com/questions/26639968/boot2docker-startup-script-to-mount-local-shared-folder-with-host) + ### Running Dockers ### In order to run the dockers, the docker has to be built, and then run with a @@ -74,7 +79,7 @@ The script that takes care of ALL of these details for you is ./docker/build_dockers.bsh -###Development in Dockers### +### Development in Dockers ### Sometimes you don't want to just build git-lfs and destroy the container, you want to get in there, run a lot of command, debug, develop, etc... To do this, @@ -150,6 +155,13 @@ exit. If set to 0, the docker containers will not be automatically deleted upon exit. This can be useful for a post mortem analysis (using other docker commands not covered here). Just make sure you clean up the docker containers manually. +`DOCKER_OTHER_OPTIONS` - Any additional arguments you may want to pass to the +docker run command. This can be particularly useful when having to help docker +with dns, etc... For example `DOCKER_OTHER_OPTIONS="--dns 8.8.8.8"` + +If for some reason on Windows, you need to add a -v mount, folder names need to +start with `//driveleter/dir...` instead of `/driveleter/dir...` to fool MINGW32 + ### Build Docker Environment Variables ### `export` before calling `run_docker.bsh`/`build_docker.bsh`. @@ -158,7 +170,7 @@ not covered here). Just make sure you clean up the docker containers manually. environment. This does not need to be bumped every version. This can be a tag or a sha. -##Deploying/Building Repositories## +## Deploying/Building Repositories ## When `./docker/run_dockers.bsh` is done building git-lfs and generating packages, it automatically creates a repository for distribution too. Each distro gets a diff --git a/docker/build_dockers.bsh b/docker/build_dockers.bsh index 398be523..3bca6072 100755 --- a/docker/build_dockers.bsh +++ b/docker/build_dockers.bsh @@ -32,8 +32,7 @@ for IMAGE_NAME in "${IMAGE_NAMES[@]}"; do fi echo Docker building ${NAME} - ${CUR_DIR}/docker+.bsh ${IMAGE_NAME} > ${CUR_DIR}/tmp.dockerfile - $SUDO docker build -t git-lfs/${NAME} -f ${CUR_DIR}/tmp.dockerfile ${CUR_DIR} - rm ${CUR_DIR}/tmp.dockerfile + ${CUR_DIR}/docker+.bsh ${IMAGE_NAME} > ${CUR_DIR}/Dockerfile + $SUDO docker build -t git-lfs/${NAME} ${CUR_DIR} + rm ${CUR_DIR}/Dockerfile done - diff --git a/docker/docker+.bsh b/docker/docker+.bsh index d9183646..4688ef34 100755 --- a/docker/docker+.bsh +++ b/docker/docker+.bsh @@ -16,11 +16,9 @@ for FILE in "${FILES[@]}"; do fi while IFS='' read -r LINE || [ -n "${LINE}" ]; do - #My template substitution - while [[ "$LINE" =~ (\[\{)([A-Za-z0-9_]*)(\}\]) ]]; do - LINE=${LINE/"${BASH_REMATCH[0]}"/${!BASH_REMATCH[2]-}} - done - + #https://gist.github.com/niclashoyer/8146033 + LINE=$(echo "$LINE" | perl -p -e 's/\[\{([^}:]+)(:([^}:]+))?\}\]/defined $ENV{$1} ? $ENV{$1} : $3/eg') + #My SOURCE substitution if echo $LINE | grep -q ^SOURCE; then SOURCE=$(echo "${LINE}" | sed -E 's|^SOURCE[ ]+(.*)|\1|') diff --git a/docker/run_dockers.bsh b/docker/run_dockers.bsh index 9bad777e..74858aab 100755 --- a/docker/run_dockers.bsh +++ b/docker/run_dockers.bsh @@ -16,6 +16,13 @@ set -eu +#Mingw32 auto converts /drive/dir/blah to drive:\dir\blah ... Can't have that. +if [[ `uname` == MINGW* ]]; then + MINGW_PATCH='/' +else + MINGW_PATCH='' +fi + CUR_DIR=$(cd $(dirname "${BASH_SOURCE[0]}"); pwd) REPO_DIR=$(cd ${CUR_DIR}/..; pwd) PACKAGE_DIR=${REPO_DIR}/repos @@ -87,12 +94,12 @@ for DOCKER_FILE in "${IMAGES[@]}"; do echo Compiling LFS in docker image ${IMAGE_NAME} IMAGE_REPO_DIR="${PACKAGE_DIR}"/"${IMAGE_INFO[1]}"/"${IMAGE_INFO[2]}" - $SUDO docker run "${OTHER_OPTIONS[@]}" \ + $SUDO docker run "${OTHER_OPTIONS[@]}" ${DOCKER_OTHER_OPTIONS-} \ -e REPO_HOSTNAME=${REPO_HOSTNAME:-git-lfs.github.com} \ -e FINAL_UID=${FINAL_UID} \ -e FINAL_GID=${FINAL_GID} \ - -v ${REPO_DIR}:/src \ - -v ${IMAGE_REPO_DIR}:/repo \ + -v "${MINGW_PATCH}${REPO_DIR}:/src" \ + -v "${MINGW_PATCH}${IMAGE_REPO_DIR}:/repo" \ git-lfs/${IMAGE_NAME} ${DOCKER_CMD-} done