Merge pull request #14 from tonistiigi/binary-targets

hack: add binary targets
docker-18.09
Tõnis Tiigi 2017-06-19 16:32:27 -07:00 committed by GitHub
commit 168fbcc873
9 changed files with 79 additions and 11 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
bin

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
bin

View File

@ -1,7 +1,37 @@
BINARIES=bin/buildd-standalone bin/buildd-containerd bin/buildctl bin/buildctl-darwin
binaries: $(BINARIES)
bin/buildctl-darwin: FORCE
mkdir -p bin
docker build --build-arg GOOS=darwin -t buildkit_poc:buildctl-darwin --target buildctl -f ./hack/dockerfiles/test.Dockerfile --force-rm .
( containerID=$$(docker create buildkit_poc:buildctl-darwin noop); \
docker cp $$containerID:/usr/bin/buildctl $@; \
docker rm $$containerID )
chmod +x $@
bin/%: FORCE
mkdir -p bin
docker build -t buildkit_poc:$* --target $* -f ./hack/dockerfiles/test.Dockerfile --force-rm .
( containerID=$$(docker create buildkit_poc:$* noop); \
docker cp $$containerID:/usr/bin/$* $@; \
docker rm $$containerID )
chmod +x $@
test:
./hack/test
lint:
./hack/lint
validate-vendor:
./hack/validate-vendor
validate-all: test lint validate-vendor
vendor:
./hack/update-vendor
.PHONY: vendor test
.PHONY: vendor test binaries lint validate-all validate-vendor
FORCE:

View File

@ -1,4 +1,4 @@
// +build linux standalone
// +build linux,standalone
package control

View File

@ -20,10 +20,25 @@ RUN git clone https://github.com/containerd/containerd.git "$GOPATH/src/github.c
&& git checkout -q "$RUNC_VERSION" \
&& make bin/containerd
FROM gobuild-base
FROM gobuild-base AS unit-tests
COPY --from=runc /usr/bin/runc /usr/bin/runc
COPY --from=containerd /go/src/github.com/containerd/containerd/bin/containerd /usr/bin/containerd
WORKDIR /go/src/github.com/tonistiigi/buildkit_poc
COPY . .
RUN go build -o /usr/bin/buildd-standalone -tags standalone ./cmd/buildd
RUN go build -o /usr/bin/buildd-containerd -tags containerd ./cmd/buildd
FROM unit-tests AS buildctl
ENV CGO_ENABLED=0
ARG GOOS=linux
RUN go build -ldflags '-d' -o /usr/bin/buildctl ./cmd/buildctl
FROM unit-tests AS buildd-standalone
ENV CGO_ENABLED=0
RUN go build -ldflags '-d' -o /usr/bin/buildd-standalone -tags standalone ./cmd/buildd
FROM unit-tests AS buildd-containerd
ENV CGO_ENABLED=0
RUN go build -ldflags '-d' -o /usr/bin/buildd-containerd -tags containerd ./cmd/buildd
FROM unit-tests AS integration-tests
COPY --from=buildd-containerd /usr/bin/buildd-containerd /usr/bin
COPY --from=buildd-standalone /usr/bin/buildd-standalone /usr/bin

View File

@ -2,9 +2,6 @@
set -eu -o pipefail -x
# update this to iidfile after 17.06
docker build -t buildkit_poc:test -f ./hack/dockerfiles/test.Dockerfile --force-rm .
docker run -v /tmp --privileged buildkit_poc:test go test ${TESTFLAGS:--v -tags 'containerd standalone'} ${TESTPKGS:-./...}
docker run --rm buildkit_poc:test go build ./...
docker run --rm buildkit_poc:test go build -tags standalone ./cmd/buildd
docker run --rm buildkit_poc:test go build -tags containerd ./cmd/buildd
./hack/test-unit
./hack/test-binaries
./hack/test-integration

8
hack/test-binaries Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -eu -o pipefail -x
# update this to iidfile after 17.06
docker build -t buildkit_poc:test --target unit-tests -f ./hack/dockerfiles/test.Dockerfile --force-rm .
docker run --rm buildkit_poc:test go build ./...
docker run -e GOOS=darwin --rm buildkit_poc:test go build ./cmd/buildctl

8
hack/test-integration Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -eu -o pipefail -x
# update this to iidfile after 17.06
docker build -t buildkit_poc:test -f ./hack/dockerfiles/test.Dockerfile --force-rm .
docker run --rm -v /tmp --privileged buildkit_poc:test go test -tags 'containerd standalone' ./client

8
hack/test-unit Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -eu -o pipefail -x
# update this to iidfile after 17.06
docker build -t buildkit_poc:test --target unit-tests -f ./hack/dockerfiles/test.Dockerfile --force-rm .
docker run --rm -v /tmp --privileged buildkit_poc:test go test ${TESTFLAGS:--v} ${TESTPKGS:-./...}