Skip to content

Commit

Permalink
Replace docker.Makefile with a bash script.
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Nephin <dnephin@docker.com>
  • Loading branch information
dnephin committed May 19, 2017
1 parent 73ebb07 commit faf70cf
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 78 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,33 @@ Docker EE products.
Development
===========

`docker/cli` is developed using Docker.
`docker/cli` is developed using Docker. The `./tasks` script is used to run
build Docker images and run Docker containers.

Build a linux binary:

```
$ make -f docker.Makefile binary
$ ./tasks binary
```

Build binaries for all supported platforms:

```
$ make -f docker.Makefile cross
$ ./tasks cross
```

Run all linting:

```
$ make -f docker.Makefile lint
$ ./tasks lint
```

### In-container development environment

Start an interactive development environment:

```
$ make -f docker.Makefile shell
$ ./tasks shell
```

In the development environment you can run many tasks, including build binaries:
Expand Down
70 changes: 0 additions & 70 deletions docker.Makefile

This file was deleted.

5 changes: 2 additions & 3 deletions dockerfiles/Dockerfile.lint
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
FROM golang:1.8-alpine

RUN apk add -U git
RUN apk add -U git make

RUN go get -u gopkg.in/alecthomas/gometalinter.v1 && \
mv /go/bin/gometalinter.v1 /usr/local/bin/gometalinter && \
gometalinter --install

WORKDIR /go/src/github.com/docker/cli
ENTRYPOINT ["/usr/local/bin/gometalinter"]
CMD ["--config=gometalinter.json", "./..."]
CMD ["/usr/local/bin/gometalinter", "--config=gometalinter.json", "./..."]
53 changes: 53 additions & 0 deletions tasks
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash

set -eu -o pipefail

dev_image=docker-cli-dev
linter_image=docker-cli-lint
cross_image=docker-cli-cross
mounts="-v $PWD:/go/src/github.com/docker/cli"

if [ -t 1 ] ; then use_tty="-ti"; else use_tty=""; fi

function run_task {
local task=$1

if [[ "$task" = *shell ]]; then
local cmd=sh
else
local cmd="make $task"
fi

case $task in
lint|lint-shell)
docker build -t "$linter_image" -f ./dockerfiles/Dockerfile.lint .
docker run --rm $use_tty $mounts "$linter_image" $cmd
;;
cross|dynbinary|cross-shell)
docker build -t "$cross_image" -f ./dockerfiles/Dockerfile.cross .
docker run --rm $use_tty $mounts "$cross_image" $cmd
;;
*)
docker build -t "$dev_image" -f ./dockerfiles/Dockerfile.dev .
docker run --rm $use_tty $mounts "$dev_image" $cmd
;;
esac
}

function usage {
cat <<USAGE
Usage: $0 TASK [TASK...]
Run a project task in the appropriate Docker image.
TASK may be the name of a target in the Makefile or one of:
shell, lint-shell, cross-shell
USAGE
exit 1
}

if [ -z "$@" ] || [ "$@" = "--help" ]; then usage; fi

for task in $@; do
run_task $task
done

0 comments on commit faf70cf

Please sign in to comment.