mirror of https://github.com/docker/cli.git
commit
e978593bd8
|
@ -2,36 +2,6 @@ version: 2
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
cross:
|
|
||||||
working_directory: /work
|
|
||||||
docker: [{image: 'docker:20.10-git'}]
|
|
||||||
environment:
|
|
||||||
DOCKER_BUILDKIT: 1
|
|
||||||
BUILDX_VERSION: "v0.6.0"
|
|
||||||
parallelism: 3
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- setup_remote_docker:
|
|
||||||
version: 20.10.6
|
|
||||||
reusable: true
|
|
||||||
exclusive: false
|
|
||||||
- run:
|
|
||||||
name: "Docker version"
|
|
||||||
command: docker version
|
|
||||||
- run:
|
|
||||||
name: "Docker info"
|
|
||||||
command: docker info
|
|
||||||
- run: apk add make curl
|
|
||||||
- run: mkdir -vp ~/.docker/cli-plugins/
|
|
||||||
- run: curl -fsSL --output ~/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.linux-amd64
|
|
||||||
- run: chmod a+x ~/.docker/cli-plugins/docker-buildx
|
|
||||||
- run: docker buildx version
|
|
||||||
- run: docker context create buildctx
|
|
||||||
- run: docker buildx create --use buildctx && docker buildx inspect --bootstrap
|
|
||||||
- run: GROUP_INDEX=$CIRCLE_NODE_INDEX GROUP_TOTAL=$CIRCLE_NODE_TOTAL docker buildx bake cross --progress=plain
|
|
||||||
- store_artifacts:
|
|
||||||
path: /work/build
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
working_directory: /work
|
working_directory: /work
|
||||||
docker: [{image: 'docker:20.10-git'}]
|
docker: [{image: 'docker:20.10-git'}]
|
||||||
|
@ -112,6 +82,5 @@ workflows:
|
||||||
version: 2
|
version: 2
|
||||||
ci:
|
ci:
|
||||||
jobs:
|
jobs:
|
||||||
- cross
|
|
||||||
- test
|
- test
|
||||||
- validate
|
- validate
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
name: build
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
- '[0-9]+.[0-9]{2}'
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
target:
|
||||||
|
- cross
|
||||||
|
- dynbinary-cross
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
-
|
||||||
|
name: Run ${{ matrix.target }}
|
||||||
|
uses: docker/bake-action@v1
|
||||||
|
with:
|
||||||
|
targets: ${{ matrix.target }}
|
||||||
|
-
|
||||||
|
name: Flatten artifacts
|
||||||
|
working-directory: ./build
|
||||||
|
run: |
|
||||||
|
for dir in */; do
|
||||||
|
base=$(basename "$dir")
|
||||||
|
echo "Creating ${base}.tar.gz ..."
|
||||||
|
tar -cvzf "${base}.tar.gz" "$dir"
|
||||||
|
rm -rf "$dir"
|
||||||
|
done
|
||||||
|
-
|
||||||
|
name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: ${{ matrix.target }}
|
||||||
|
path: ./build/*
|
||||||
|
if-no-files-found: error
|
25
Makefile
25
Makefile
|
@ -3,7 +3,6 @@
|
||||||
#
|
#
|
||||||
all: binary
|
all: binary
|
||||||
|
|
||||||
|
|
||||||
_:=$(shell ./scripts/warn-outside-container $(MAKECMDGOALS))
|
_:=$(shell ./scripts/warn-outside-container $(MAKECMDGOALS))
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
@ -21,22 +20,30 @@ test: test-unit ## run tests
|
||||||
test-coverage: ## run test coverage
|
test-coverage: ## run test coverage
|
||||||
gotestsum -- -coverprofile=coverage.txt $(shell go list ./... | grep -vE '/vendor/|/e2e/')
|
gotestsum -- -coverprofile=coverage.txt $(shell go list ./... | grep -vE '/vendor/|/e2e/')
|
||||||
|
|
||||||
|
.PHONY: lint
|
||||||
|
lint: ## run all the lint tools
|
||||||
|
golangci-lint run
|
||||||
|
|
||||||
|
.PHONY: shellcheck
|
||||||
|
shellcheck: ## run shellcheck validation
|
||||||
|
find scripts/ contrib/completion/bash -type f | grep -v scripts/winresources | grep -v '.*.ps1' | xargs shellcheck
|
||||||
|
|
||||||
.PHONY: fmt
|
.PHONY: fmt
|
||||||
fmt:
|
fmt:
|
||||||
go list -f {{.Dir}} ./... | xargs gofmt -w -s -d
|
go list -f {{.Dir}} ./... | xargs gofmt -w -s -d
|
||||||
|
|
||||||
.PHONY: binary
|
.PHONY: binary
|
||||||
binary:
|
binary: ## build executable for Linux
|
||||||
docker buildx bake binary
|
./scripts/build/binary
|
||||||
|
|
||||||
|
.PHONY: dynbinary
|
||||||
|
dynbinary: ## build dynamically linked binary
|
||||||
|
GO_LINKMODE=dynamic ./scripts/build/binary
|
||||||
|
|
||||||
.PHONY: plugins
|
.PHONY: plugins
|
||||||
plugins: ## build example CLI plugins
|
plugins: ## build example CLI plugins
|
||||||
./scripts/build/plugins
|
./scripts/build/plugins
|
||||||
|
|
||||||
.PHONY: cross
|
|
||||||
cross:
|
|
||||||
docker buildx bake cross
|
|
||||||
|
|
||||||
.PHONY: plugins-windows
|
.PHONY: plugins-windows
|
||||||
plugins-windows: ## build example CLI plugins for Windows
|
plugins-windows: ## build example CLI plugins for Windows
|
||||||
./scripts/build/plugins-windows
|
./scripts/build/plugins-windows
|
||||||
|
@ -45,10 +52,6 @@ plugins-windows: ## build example CLI plugins for Windows
|
||||||
plugins-osx: ## build example CLI plugins for macOS
|
plugins-osx: ## build example CLI plugins for macOS
|
||||||
./scripts/build/plugins-osx
|
./scripts/build/plugins-osx
|
||||||
|
|
||||||
.PHONY: dynbinary
|
|
||||||
dynbinary: ## build dynamically linked binary
|
|
||||||
USE_GLIBC=1 docker buildx bake dynbinary
|
|
||||||
|
|
||||||
vendor: vendor.conf ## check that vendor matches vendor.conf
|
vendor: vendor.conf ## check that vendor matches vendor.conf
|
||||||
rm -rf vendor
|
rm -rf vendor
|
||||||
bash -c 'vndr |& grep -v -i clone | tee ./vndr.log'
|
bash -c 'vndr |& grep -v -i clone | tee ./vndr.log'
|
||||||
|
|
53
README.md
53
README.md
|
@ -1,64 +1,67 @@
|
||||||
[![build status](https://circleci.com/gh/docker/cli.svg?style=shield)](https://circleci.com/gh/docker/cli/tree/master)
|
# Docker CLI
|
||||||
[![Build Status](https://ci.docker.com/public/job/cli/job/master/badge/icon)](https://ci.docker.com/public/job/cli/job/master)
|
|
||||||
|
|
||||||
docker/cli
|
[![PkgGoDev](https://img.shields.io/badge/go.dev-docs-007d9c?logo=go&logoColor=white)](https://pkg.go.dev/github.com/docker/cli)
|
||||||
==========
|
[![Build Status](https://img.shields.io/github/workflow/status/docker/cli/build?logo=github)](https://github.com/docker/cli/actions?query=workflow%3Abuild)
|
||||||
|
[![CircleCI Status](https://img.shields.io/circleci/build/github/docker/cli/master?logo=circleci)](https://circleci.com/gh/docker/cli/tree/master)
|
||||||
|
[![Jenkins Status](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fci.docker.com%2Fpublic%2Fjob%2Fcli%2Fjob%2Fmaster&logo=jenkins)](https://ci.docker.com/public/job/cli/job/master)
|
||||||
|
[![Go Report Card](https://goreportcard.com/badge/github.com/docker/cli)](https://goreportcard.com/report/github.com/docker/cli)
|
||||||
|
[![Codecov](https://codecov.io/gh/docker/cli/branch/master/graph/badge.svg)](https://codecov.io/gh/docker/cli)
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
This repository is the home of the cli used in the Docker CE and
|
This repository is the home of the cli used in the Docker CE and
|
||||||
Docker EE products.
|
Docker EE products.
|
||||||
|
|
||||||
Development
|
## Development
|
||||||
===========
|
|
||||||
|
|
||||||
`docker/cli` is developed using Docker.
|
`docker/cli` is developed using Docker.
|
||||||
|
|
||||||
Build CLI from source:
|
Build CLI from source:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
$ docker buildx bake
|
docker buildx bake
|
||||||
```
|
```
|
||||||
|
|
||||||
Build binaries for all supported platforms:
|
Build binaries for all supported platforms:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
$ docker buildx bake cross
|
docker buildx bake cross
|
||||||
```
|
```
|
||||||
|
|
||||||
Build for a specific platform:
|
Build for a specific platform:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
$ docker buildx bake --set binary.platform=linux/arm64
|
docker buildx bake --set binary.platform=linux/arm64
|
||||||
```
|
```
|
||||||
|
|
||||||
Build dynamic binary for glibc or musl:
|
Build dynamic binary for glibc or musl:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
USE_GLIBC=1 docker buildx bake dynbinary
|
||||||
```
|
```
|
||||||
$ USE_GLIBC=1 docker buildx bake dynbinary
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
Run all linting:
|
Run all linting:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
$ make -f docker.Makefile lint
|
docker buildx bake lint shellcheck
|
||||||
```
|
```
|
||||||
|
|
||||||
List all the available targets:
|
List all the available targets:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
$ make help
|
make help
|
||||||
```
|
```
|
||||||
|
|
||||||
### In-container development environment
|
### In-container development environment
|
||||||
|
|
||||||
Start an interactive development environment:
|
Start an interactive development environment:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
$ make -f docker.Makefile shell
|
make -f docker.Makefile shell
|
||||||
```
|
```
|
||||||
|
|
||||||
Legal
|
## Legal
|
||||||
=====
|
|
||||||
*Brought to you courtesy of our legal counsel. For more context,
|
*Brought to you courtesy of our legal counsel. For more context,
|
||||||
please see the [NOTICE](https://github.com/docker/cli/blob/master/NOTICE) document in this repo.*
|
please see the [NOTICE](https://github.com/docker/cli/blob/master/NOTICE) document in this repo.*
|
||||||
|
|
||||||
|
@ -70,8 +73,8 @@ violate applicable laws.
|
||||||
|
|
||||||
For more information, please see https://www.bis.doc.gov
|
For more information, please see https://www.bis.doc.gov
|
||||||
|
|
||||||
Licensing
|
## Licensing
|
||||||
=========
|
|
||||||
docker/cli is licensed under the Apache License, Version 2.0. See
|
docker/cli is licensed under the Apache License, Version 2.0. See
|
||||||
[LICENSE](https://github.com/docker/docker/blob/master/LICENSE) for the full
|
[LICENSE](https://github.com/docker/docker/blob/master/LICENSE) for the full
|
||||||
license text.
|
license text.
|
||||||
|
|
|
@ -32,34 +32,16 @@ target "dynbinary" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "GROUP_TOTAL" {
|
target "platforms" {
|
||||||
default = "1"
|
platforms = concat(["linux/amd64", "linux/386", "linux/arm64", "linux/arm", "linux/ppc64le", "linux/s390x", "darwin/amd64", "darwin/arm64", "windows/amd64", "windows/arm", "windows/386"], USE_GLIBC!=""?[]:["windows/arm64"])
|
||||||
}
|
|
||||||
|
|
||||||
variable "GROUP_INDEX" {
|
|
||||||
default = "0"
|
|
||||||
}
|
|
||||||
|
|
||||||
function "platforms" {
|
|
||||||
params = [USE_GLIBC]
|
|
||||||
result = concat(["linux/amd64", "linux/386", "linux/arm64", "linux/arm", "linux/ppc64le", "linux/s390x", "darwin/amd64", "darwin/arm64", "windows/amd64", "windows/arm", "windows/386"], USE_GLIBC!=""?[]:["windows/arm64"])
|
|
||||||
}
|
|
||||||
|
|
||||||
function "glen" {
|
|
||||||
params = [platforms, GROUP_TOTAL]
|
|
||||||
result = ceil(length(platforms)/GROUP_TOTAL)
|
|
||||||
}
|
|
||||||
|
|
||||||
target "_all_platforms" {
|
|
||||||
platforms = slice(platforms(USE_GLIBC), GROUP_INDEX*glen(platforms(USE_GLIBC), GROUP_TOTAL),min(length(platforms(USE_GLIBC)), (GROUP_INDEX+1)*glen(platforms(USE_GLIBC), GROUP_TOTAL)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
target "cross" {
|
target "cross" {
|
||||||
inherits = ["binary", "_all_platforms"]
|
inherits = ["binary", "platforms"]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "dynbinary-cross" {
|
target "dynbinary-cross" {
|
||||||
inherits = ["dynbinary", "_all_platforms"]
|
inherits = ["dynbinary", "platforms"]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "lint" {
|
target "lint" {
|
||||||
|
|
|
@ -42,8 +42,9 @@ build_e2e_image:
|
||||||
DOCKER_RUN_NAME_OPTION := $(if $(DOCKER_CLI_CONTAINER_NAME),--name $(DOCKER_CLI_CONTAINER_NAME),)
|
DOCKER_RUN_NAME_OPTION := $(if $(DOCKER_CLI_CONTAINER_NAME),--name $(DOCKER_CLI_CONTAINER_NAME),)
|
||||||
DOCKER_RUN := docker run --rm $(ENVVARS) $(DOCKER_CLI_MOUNTS) $(DOCKER_RUN_NAME_OPTION)
|
DOCKER_RUN := docker run --rm $(ENVVARS) $(DOCKER_CLI_MOUNTS) $(DOCKER_RUN_NAME_OPTION)
|
||||||
|
|
||||||
binary: build_binary_native_image ## build the CLI
|
.PHONY: binary
|
||||||
$(DOCKER_RUN) $(BINARY_NATIVE_IMAGE_NAME)
|
binary:
|
||||||
|
docker buildx bake binary
|
||||||
|
|
||||||
build: binary ## alias for binary
|
build: binary ## alias for binary
|
||||||
|
|
||||||
|
@ -62,6 +63,10 @@ test-unit: build_docker_image ## run unit tests (using go test)
|
||||||
.PHONY: test ## run unit and e2e tests
|
.PHONY: test ## run unit and e2e tests
|
||||||
test: test-unit test-e2e
|
test: test-unit test-e2e
|
||||||
|
|
||||||
|
.PHONY: cross
|
||||||
|
cross:
|
||||||
|
docker buildx bake cross
|
||||||
|
|
||||||
.PHONY: plugins-windows
|
.PHONY: plugins-windows
|
||||||
plugins-windows: build_cross_image ## build the example CLI plugins for Windows
|
plugins-windows: build_cross_image ## build the example CLI plugins for Windows
|
||||||
$(DOCKER_RUN) $(CROSS_IMAGE_NAME) make $@
|
$(DOCKER_RUN) $(CROSS_IMAGE_NAME) make $@
|
||||||
|
@ -70,6 +75,10 @@ plugins-windows: build_cross_image ## build the example CLI plugins for Windows
|
||||||
plugins-osx: build_cross_image ## build the example CLI plugins for macOS
|
plugins-osx: build_cross_image ## build the example CLI plugins for macOS
|
||||||
$(DOCKER_RUN) $(CROSS_IMAGE_NAME) make $@
|
$(DOCKER_RUN) $(CROSS_IMAGE_NAME) make $@
|
||||||
|
|
||||||
|
.PHONY: dynbinary
|
||||||
|
dynbinary: ## build dynamically linked binary
|
||||||
|
USE_GLIBC=1 docker buildx bake dynbinary
|
||||||
|
|
||||||
.PHONY: dev
|
.PHONY: dev
|
||||||
dev: build_docker_image ## start a build container in interactive mode for in-container development
|
dev: build_docker_image ## start a build container in interactive mode for in-container development
|
||||||
$(DOCKER_RUN) -it \
|
$(DOCKER_RUN) -it \
|
||||||
|
@ -82,6 +91,10 @@ shell: dev ## alias for dev
|
||||||
lint: ## run linters
|
lint: ## run linters
|
||||||
docker buildx bake lint
|
docker buildx bake lint
|
||||||
|
|
||||||
|
.PHONY: shellcheck
|
||||||
|
shellcheck: ## run shellcheck validation
|
||||||
|
docker buildx bake shellcheck
|
||||||
|
|
||||||
.PHONY: fmt
|
.PHONY: fmt
|
||||||
fmt: ## run gofmt
|
fmt: ## run gofmt
|
||||||
$(DOCKER_RUN) $(DEV_DOCKER_IMAGE_NAME) make fmt
|
$(DOCKER_RUN) $(DEV_DOCKER_IMAGE_NAME) make fmt
|
||||||
|
@ -102,10 +115,6 @@ manpages: build_docker_image ## generate man pages from go source and markdown
|
||||||
yamldocs: build_docker_image ## generate documentation YAML files consumed by docs repo
|
yamldocs: build_docker_image ## generate documentation YAML files consumed by docs repo
|
||||||
$(DOCKER_RUN) -it $(DEV_DOCKER_IMAGE_NAME) make yamldocs
|
$(DOCKER_RUN) -it $(DEV_DOCKER_IMAGE_NAME) make yamldocs
|
||||||
|
|
||||||
.PHONY: shellcheck
|
|
||||||
shellcheck: ## run shellcheck validation
|
|
||||||
docker buildx bake shellcheck
|
|
||||||
|
|
||||||
.PHONY: test-e2e
|
.PHONY: test-e2e
|
||||||
test-e2e: test-e2e-non-experimental test-e2e-experimental test-e2e-connhelper-ssh ## run all e2e tests
|
test-e2e: test-e2e-non-experimental test-e2e-experimental test-e2e-connhelper-ssh ## run all e2e tests
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
ARG GO_VERSION=1.13.15
|
|
||||||
|
|
||||||
FROM dockercore/golang-cross:${GO_VERSION}
|
|
||||||
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
|
|
||||||
WORKDIR /go/src/github.com/docker/cli
|
|
||||||
COPY . .
|
|
Loading…
Reference in New Issue