Skip to content

Commit

Permalink
Merge pull request #62 from avast/FixCommandsExecution
Browse files Browse the repository at this point in the history
Fix commands execution
  • Loading branch information
augi authored Mar 3, 2017
2 parents a531b06 + d1ecc53 commit 5ed9217
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 19 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ language: generic

sudo: required
env:
- DOCKER_VERSION=1.12.3
- DOCKER_VERSION=1.11.2
- DOCKER_VERSION=1.10.3
- DOCKER_VERSION=1.13.1 DOCKER_PACKAGE_VERSION=$DOCKER_VERSION-0~ubuntu-precise
- DOCKER_VERSION=1.12.6 DOCKER_PACKAGE_VERSION=$DOCKER_VERSION-0~ubuntu-precise
- DOCKER_VERSION=1.11.2 DOCKER_PACKAGE_VERSION=$DOCKER_VERSION-0~precise

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
Expand All @@ -16,12 +16,12 @@ cache:

before_install:
- curl -sSL https://get.docker.com/ | sh
- sudo apt-get -y --force-yes install docker-engine=$DOCKER_VERSION-0~precise
- sudo apt-get -y --force-yes install docker-engine=$DOCKER_PACKAGE_VERSION
# Build image with building environment
- sudo docker build --tag=build-image .

script:
- sudo docker run -v $(pwd):/build -v $HOME/.m2:/root/.m2 -v $HOME/.gradle:/root/.gradle -v /var/run/docker.sock:/var/run/docker.sock build-image test --info

after_success:
- test $TRAVIS_PULL_REQUEST == "false" && test "$TRAVIS_TAG" != "" && test $TRAVIS_REPO_SLUG == "avast/docker-compose-gradle-plugin" && test $DOCKER_VERSION == "1.12.3" && sudo docker run -v $(pwd):/build -v $HOME/.m2:/root/.m2 -v $HOME/.gradle:/root/.gradle -v /var/run/docker.sock:/var/run/docker.sock -e "BINTRAY_USER=$BINTRAY_USER" -e "BINTRAY_KEY=$BINTRAY_KEY" -e "GRADLE_PORTAL_KEY=$GRADLE_PORTAL_KEY" -e "GRADLE_PORTAL_SECRET=$GRADLE_PORTAL_SECRET" build-image bintrayUpload publishPlugins -Pversion="$TRAVIS_TAG" --info
- test $TRAVIS_PULL_REQUEST == "false" && test "$TRAVIS_TAG" != "" && test $TRAVIS_REPO_SLUG == "avast/docker-compose-gradle-plugin" && test $DOCKER_VERSION == "1.13.1" && sudo docker run -v $(pwd):/build -v $HOME/.m2:/root/.m2 -v $HOME/.gradle:/root/.gradle -v /var/run/docker.sock:/var/run/docker.sock -e "BINTRAY_USER=$BINTRAY_USER" -e "BINTRAY_KEY=$BINTRAY_KEY" -e "GRADLE_PORTAL_KEY=$GRADLE_PORTAL_KEY" -e "GRADLE_PORTAL_SECRET=$GRADLE_PORTAL_SECRET" build-image bintrayUpload publishPlugins -Pversion="$TRAVIS_TAG" --info
13 changes: 2 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
# This is Dockerfile that defines build environment.
FROM java:8-jdk
FROM java:8u111-jdk-alpine
MAINTAINER [email protected]

# install Docker
ENV DOCKER_VERSION=1.10.2
RUN curl -sSL -O https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION} \
&& chmod +x docker-${DOCKER_VERSION} \
&& mv docker-${DOCKER_VERSION} /usr/local/bin/docker

# install docker-compose
ENV COMPOSE_VERSION 1.6.2
RUN curl -o /usr/local/bin/docker-compose -L "https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-Linux-x86_64" \
&& chmod +x /usr/local/bin/docker-compose
RUN apk add --update libstdc++ docker=1.11.2-r1 py-pip=8.1.2-r0 && rm -rf /var/cache/apk/* && pip install --no-cache-dir docker-compose==1.11.2

# allow to bind local Docker to the outer Docker
VOLUME /var/run/docker.sock
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ dockerCompose {
// removeImages = "None" // Other accepted values are: "All" and "Local"
// removeVolumes = false
// projectName = 'my-project' // allow to set custom docker-compose project name (defaults to directory name)
// executable = '/path/to/docker-compose' // allow to set the path of the docker-compose executable if not present in PATH
// executable = '/path/to/docker-compose' // allow to set the path of the docker-compose executable (usefull if not present in PATH)
// dockerExecutable = '/path/to/docker' // allow to set the path of the docker executable (usefull if not present in PATH)
// environment.put 'BACKEND_ADDRESS', '192.168.1.100' // Pass environment variable to 'docker-compose' for substitution in compose file
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class ComposeExtension {
String executable = 'docker-compose'
Map<String, Object> environment = new HashMap<String, Object>(System.getenv());

String dockerExecutable = 'docker'

ComposeExtension(Project project, ComposeUp upTask, ComposeDown downTask) {
this.project = project
this.downTask = downTask
Expand Down Expand Up @@ -89,6 +91,13 @@ class ComposeExtension {
res
}

@PackageScope
Iterable<String> dockerCommand(String... args) {
def res = [dockerExecutable]
res.addAll(args)
res
}

VersionNumber getDockerComposeVersion() {
def p = this.project
def env = this.environment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ComposeUp extends DefaultTask {
@Override
void run() {
project.exec { ExecSpec e ->
e.environment = extension.environment
e.commandLine extension.composeCommand('logs', '-f', '--no-color')
e.standardOutput = new OutputStream() {
def buffer = new ArrayList<Byte>()
Expand Down Expand Up @@ -163,7 +164,8 @@ class ComposeUp extends DefaultTask {
Map<String, Object> getDockerInspection(String containerId) {
new ByteArrayOutputStream().withStream { os ->
project.exec { ExecSpec e ->
e.commandLine 'docker', 'inspect', containerId
e.environment = extension.environment
e.commandLine extension.dockerCommand('inspect', containerId)
e.standardOutput os
}
def inspectionAsString = os.toString()
Expand Down Expand Up @@ -302,7 +304,8 @@ class ComposeUp extends DefaultTask {
def containerId = getContainerId(serviceName)
new ByteArrayOutputStream().withStream { os ->
project.exec { ExecSpec e ->
e.commandLine 'docker', 'logs', '--follow=false', containerId
e.environment = extension.environment
e.commandLine extension.dockerCommand('logs', '--follow=false', containerId)
e.standardOutput = os
}
os.toString().trim()
Expand Down

0 comments on commit 5ed9217

Please sign in to comment.