Bläddra i källkod

alpine docker image for running compose and a script to pull and run it with the
correct volumes.

Signed-off-by: Daniel Nephin <[email protected]>

Daniel Nephin 10 år sedan
förälder
incheckning
39cea970b8
4 ändrade filer med 86 tillägg och 5 borttagningar
  1. 1 1
      .dockerignore
  2. 15 0
      Dockerfile.run
  3. 22 4
      docs/install.md
  4. 48 0
      script/run

+ 1 - 1
.dockerignore

@@ -4,6 +4,6 @@
 .tox
 build
 coverage-html
-dist
 docs/_site
 venv
+.tox

+ 15 - 0
Dockerfile.run

@@ -0,0 +1,15 @@
+
+FROM    alpine:edge
+RUN     apk -U add \
+            python \
+            py-pip
+
+COPY    requirements.txt /code/requirements.txt
+RUN     pip install -r /code/requirements.txt
+
+ENV     VERSION 1.4.0dev
+
+COPY    dist/docker-compose-$VERSION.tar.gz /code/docker-compose/
+RUN     pip install /code/docker-compose/docker-compose-$VERSION/
+
+ENTRYPOINT ["/usr/bin/docker-compose"]

+ 22 - 4
docs/install.md

@@ -40,20 +40,38 @@ To install Compose, do the following:
 
         curl -L https://github.com/docker/compose/releases/download/VERSION_NUM/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
 
-     If you have problems installing with `curl`, you can use `pip` instead: `pip install -U docker-compose`
+     If you have problems installing with `curl`, see
+     [Alternative Install Options](#alternative-install-options).
 
-4. Apply executable permissions to the binary:
+5. Apply executable permissions to the binary:
 
         $ chmod +x /usr/local/bin/docker-compose
 
-5.  Optionally, install [command completion](completion.md) for the
+6.  Optionally, install [command completion](completion.md) for the
 `bash` and `zsh` shell.
 
-6. Test the installation.
+7. Test the installation.
 
         $ docker-compose --version
         docker-compose version: 1.4.2
 
+
+## Alternative install options
+
+### Install using pip
+
+    $ sudo pip install -U docker-compose
+
+
+### Install as a container
+
+Compose can also be run inside a container, from a small bash script wrapper.
+To install compose as a container run:
+
+    $ curl -L https://github.com/docker/compose/releases/download/1.5.0/compose-run > /usr/local/bin/docker-compose
+    $ chmod +x /usr/local/bin/docker-compose
+
+
 ## Upgrading
 
 If you're upgrading from Compose 1.2 or earlier, you'll need to remove or migrate

+ 48 - 0
script/run

@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# Run docker-compose in a container
+#
+# This script will attempt to mirror the host paths by using volumes for the
+# following paths:
+#   * $(pwd)
+#   * $(dirname $COMPOSE_FILE) if it's set
+#   * $HOME if it's set
+#
+# You can add additional volumes (or any docker run options) using
+# the $COMPOSE_OPTIONS environment variable.
+#
+
+
+set -e
+
+VERSION="1.4.0dev"
+# TODO: move this to an official repo
+IMAGE="dnephin/docker-compose:$VERSION"
+
+
+# Setup options for connecting to docker host
+if [ -z "$DOCKER_HOST" ]; then
+    DOCKER_HOST="/var/run/docker.sock"
+fi
+if [ -S "$DOCKER_HOST" ]; then
+    DOCKER_ADDR="-v $DOCKER_HOST:$DOCKER_HOST -e DOCKER_HOST"
+else
+    DOCKER_ADDR="-e DOCKER_HOST"
+fi
+
+
+# Setup volume mounts for compose config and context
+VOLUMES="-v $(pwd):$(pwd)"
+if [ -n "$COMPOSE_FILE" ]; then
+    compose_dir=$(dirname $COMPOSE_FILE)
+fi
+# TODO: also check --file argument
+if [ -n "$compose_dir" ]; then
+    VOLUMES="$VOLUMES -v $compose_dir:$compose_dir"
+fi
+if [ -n "$HOME" ]; then
+    VOLUMES="$VOLUMES -v $HOME:$HOME"
+fi
+
+
+exec docker run --rm -ti $DOCKER_ADDR $COMPOSE_OPTIONS $VOLUMES -w $(pwd) $IMAGE $@