-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Docker image and bash script for running compose in a container #1806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,6 @@ | |
| .tox | ||
| build | ||
| coverage-html | ||
| dist | ||
| docs/_site | ||
| venv | ||
| .tox | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll open an issue to get this image published to a better repo, and add notes to the release process doc about updating it on release. |
||
|
|
||
|
|
||
| # 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)" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not use "$PWD" (which will be set by the shell) and avoid the subshells here?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would probably work as well. There are times when Does this cause a problem? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No serious problem, just calling out the unnecessary subshell. |
||
| 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" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does everything work fine if
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ya, that doesn't seem to be a problem from what I can tell |
||
| fi | ||
|
|
||
|
|
||
| exec docker run --rm -ti $DOCKER_ADDR $COMPOSE_OPTIONS $VOLUMES -w $(pwd) $IMAGE $@ | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You write really helpful doc strings for your bash scripts 👍