Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.DS_Store
build
./build
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ lint:
cross: clean
@./scripts/build/cross

dynbinary: clean
@./scripts/build/dynbinary

# download dependencies (vendor/) listed in vendor.conf
.PHONY: vendor
vendor: vendor.conf
Expand Down
11 changes: 11 additions & 0 deletions docker.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

DEV_DOCKER_IMAGE_NAME = docker-cli-dev
LINTER_IMAGE_NAME = docker-cli-lint
CROSS_IMAGE_NAME = docker-cli-cross
MOUNTS = -v `pwd`:/go/src/github.com/docker/cli

# build docker image (dockerfiles/Dockerfile.build)
Expand All @@ -18,6 +19,11 @@ build_docker_image:
build_linter_image:
@docker build -q -t $(LINTER_IMAGE_NAME) -f ./dockerfiles/Dockerfile.lint .

.PHONY: build_cross_image
build_cross_image:
@docker build -t $(CROSS_IMAGE_NAME) -f ./dockerfiles/Dockerfile.cross .


# build executable using a container
.PHONY: build
build: build_docker_image
Expand All @@ -44,6 +50,8 @@ cross: build_docker_image
dev: build_docker_image
@docker run -ti $(MOUNTS) -v /var/run/docker.sock:/var/run/docker.sock $(DEV_DOCKER_IMAGE_NAME) ash

shell: dev

# run linters in a container
.PHONY: lint
lint: build_linter_image
Expand All @@ -53,3 +61,6 @@ lint: build_linter_image
.PHONY: vendor
vendor: build_docker_image vendor.conf
@docker run -ti --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make vendor

dynbinary: build_cross_image
@docker run -ti --rm $(MOUNTS) $(CROSS_IMAGE_NAME) make dynbinary
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

FROM golang:1.8-alpine

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

RUN go get github.com/LK4D4/vndr && \
cp /go/bin/vndr /usr/bin && \
Expand Down
8 changes: 8 additions & 0 deletions dockerfiles/Dockerfile.cross
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

FROM golang:1.8.1

# allow replacing httpredir or deb mirror
ARG APT_MIRROR=deb.debian.org
RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list

WORKDIR /go/src/github.com/docker/cli
4 changes: 3 additions & 1 deletion scripts/build/binary
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env sh
#!/usr/bin/env bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This was causing builds to fail in ubuntu-xenial containers due to the default /usr/bin/env sh not having source


set -eu -o pipefail

source ./scripts/build/ldflags

Expand Down
10 changes: 10 additions & 0 deletions scripts/build/dynbinary
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -eu -o pipefail

source ./scripts/build/ldflags

go build \
-o ./build/docker \
--ldflags "${LDFLAGS}" \
github.com/docker/cli/cmd/docker
10 changes: 7 additions & 3 deletions scripts/build/ldflags
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ VERSION=${VERSION:-"unknown-version"}
GITCOMMIT=${GITCOMMIT:-$(git rev-parse --short HEAD 2> /dev/null || true)}
BUILDTIME=${BUILDTIME:-$(date --utc --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/')}

export LDFLAGS="-X github.com/docker/cli/cli.GitCommit=${GITCOMMIT} \
-X github.com/docker/cli/cli.BuildTime=${BUILDTIME} \
-X github.com/docker/cli/cli.Version=${VERSION} ${LDFLAGS}"
export LDFLAGS="\
-w \
-X github.com/docker/cli/cli.GitCommit=${GITCOMMIT} \
-X github.com/docker/cli/cli.BuildTime=${BUILDTIME} \
-X github.com/docker/cli/cli.Version=${VERSION} \
${LDFLAGS:-} \
"