Last active
May 10, 2016 08:52
-
-
Save james-nesbitt/066fefff833b5ae84fd828f4e13036af to your computer and use it in GitHub Desktop.
composer in a container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# How to use me: | |
# 1. put me into any bin path, or run me using a full path (probably make me executable.) | |
# 2. cd into any path that has a composer.json file | |
# 3. run me, and pass me any flags that you would pass to composer | |
# | |
# define which image to use as a command shell image | |
# | |
# * this image is still under development, and has some quirks. | |
# * you will need to occasionally update this image: docker pull quay.io/wunder/wundertools-image-fuzzy-developershell | |
# * you can report any image related issues here: https://github.com/wunderkraut/wundertools-image-fuzzy-developershell/issues | |
# | |
DOCKER_IMAGE_DEVELOPERTOOL="quay.io/wunder/wundertools-image-fuzzy-developershell" | |
# define what paths are used to bind/mount into the container | |
PATH_TARGET="$(pwd)" | |
PATH_HOME="${HOME}" | |
# Run a container: | |
# | |
# --rm -ti : remove the container after running, give it a tty, and attach input | |
# | |
# Map 3 host paths into the container | |
# --volume="${PATH_TARGET}:/app/target" \ <-- the current host path will be our composer target, mapped to /app/target | |
# --volume="${PATH_HOME}/.gitconfig:/app/.gitconfig" \ <-- composer may need to use ssh, so use the host keys | |
# --volume="${PATH_HOME}/.ssh:/app/.ssh" \ <-- composer may use a github token, so save it if so | |
# | |
# Tell docker what image command to run inside the container | |
# --entrypoint=composer \ | |
# | |
# Tell docker what directory to run the command inside the container | |
# -w=/app/target \ | |
# | |
# $@ will pass all command arguments to the docker command, so composer receives your command | |
# | |
docker run --rm -t -i \ | |
--volume="${PATH_TARGET}:/app/target" \ | |
--volume="${PATH_HOME}/.gitconfig:/app/.gitconfig" \ | |
--volume="${PATH_HOME}/.ssh:/app/.ssh" \ | |
--entrypoint=composer \ | |
-w=/app/target \ | |
${DOCKER_IMAGE_DEVELOPERTOOL} \ | |
$@ | |
# | |
# Notes: | |
# | |
# * The will run composer inside a container, AND THEN REMOVE THE CONTAINER and all of the container changes | |
# * this process is not perfect, and may once in a while require some manual support in removing dead containers | |
# | |
# - composer will be run inside the conatiner at /app/target. so errors and warnings will be at a related path | |
# - if composer produces and exception, the container will exit, but will not remove itself. You will need to clean it yourself | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment