Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 3aaec6a

Browse files
committed
split compose-cli "docker" and composeV2 cli-plugin release processes
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 2605aae commit 3aaec6a

File tree

12 files changed

+85
-60
lines changed

12 files changed

+85
-60
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
# Ensure we don't discover cross platform build issues at release time.
6161
# Time used to build linux here is gained back in the build for local E2E step
6262
- name: Build packages
63-
run: make -f builder.Makefile cross
63+
run: make -f builder.Makefile cross cross-compose-plugin
6464

6565
build:
6666
name: Build
@@ -99,7 +99,7 @@ jobs:
9999
- name: Build for local E2E
100100
env:
101101
BUILD_TAGS: e2e
102-
run: make -f builder.Makefile cli
102+
run: make -f builder.Makefile cli compose-plugin
103103

104104
- name: E2E Test
105105
run: make e2e-local

.github/workflows/release.yaml renamed to .github/workflows/cli-release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Releaser
33
on:
44
push:
55
tags:
6-
- "v*"
6+
- "v1*"
77
jobs:
88
upload-release:
99
runs-on: ubuntu-latest
@@ -30,10 +30,10 @@ jobs:
3030
${{ runner.os }}-go-
3131
3232
- name: Build
33-
run: make -f builder.Makefile package
33+
run: make -f builder.Makefile cross
3434

3535
- uses: ncipollo/release-action@v1
3636
with:
37-
artifacts: "dist/*"
37+
artifacts: "bin/*"
3838
prerelease: true
3939
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/plugin-release.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Releaser
2+
3+
on:
4+
push:
5+
tags:
6+
- "v2*"
7+
jobs:
8+
upload-release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Set up Go 1.16
12+
uses: actions/setup-go@v2
13+
with:
14+
go-version: 1.16
15+
id: go
16+
17+
- name: Setup docker CLI
18+
run: |
19+
curl https://download.docker.com/linux/static/stable/x86_64/docker-20.10.3.tgz | tar xz
20+
sudo cp ./docker/docker /usr/bin/ && rm -rf docker && docker version
21+
22+
- name: Checkout code into the Go module directory
23+
uses: actions/checkout@v2
24+
25+
- uses: actions/cache@v2
26+
with:
27+
path: ~/go/pkg/mod
28+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
29+
restore-keys: |
30+
${{ runner.os }}-go-
31+
32+
- name: Build
33+
run: make -f builder.Makefile cross-compose-plugin
34+
35+
- uses: ncipollo/release-action@v1
36+
with:
37+
artifacts: "bin/*"
38+
prerelease: true
39+
token: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,22 @@ RUN --mount=target=. \
7575
GOARCH=${TARGETARCH} \
7676
BUILD_TAGS=${BUILD_TAGS} \
7777
GIT_TAG=${GIT_TAG} \
78-
make BINARY=/out/docker COMPOSE_BINARY=/out/docker-compose -f builder.Makefile cli
78+
make BINARY=/out/docker -f builder.Makefile cli
79+
80+
FROM base AS make-compose-plugin
81+
ENV CGO_ENABLED=0
82+
ARG TARGETOS
83+
ARG TARGETARCH
84+
ARG BUILD_TAGS
85+
ARG GIT_TAG
86+
RUN --mount=target=. \
87+
--mount=type=cache,target=/go/pkg/mod \
88+
--mount=type=cache,target=/root/.cache/go-build \
89+
GOOS=${TARGETOS} \
90+
GOARCH=${TARGETARCH} \
91+
BUILD_TAGS=${BUILD_TAGS} \
92+
GIT_TAG=${GIT_TAG} \
93+
make COMPOSE_BINARY=/out/docker-compose -f builder.Makefile compose-plugin
7994

8095
FROM base AS make-cross
8196
ARG BUILD_TAGS
@@ -93,6 +108,9 @@ COPY --from=make-protos /compose-cli/cli/server/protos .
93108
FROM scratch AS cli
94109
COPY --from=make-cli /out/* .
95110

111+
FROM scratch AS compose-plugin
112+
COPY --from=make-compose-plugin /out/* .
113+
96114
FROM scratch AS cross
97115
COPY --from=make-cross /out/* .
98116

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ else
3131
TEST_FLAGS=-run $(E2E_TEST)
3232
endif
3333

34-
all: cli
34+
all: cli compose-plugin
3535

3636
protos: ## Generate go code from .proto files
3737
@docker build . --target protos \
@@ -44,6 +44,13 @@ cli: ## Compile the cli
4444
--build-arg GIT_TAG=$(GIT_TAG) \
4545
--output ./bin
4646

47+
compose-plugin: ## Compile the compose cli-plugin
48+
@docker build . --target compose-plugin \
49+
--platform local \
50+
--build-arg BUILD_TAGS=e2e,kube \
51+
--build-arg GIT_TAG=$(GIT_TAG) \
52+
--output ./bin
53+
4754
e2e-local: ## Run End to end local tests. Set E2E_TEST=TestName to run a single test
4855
gotestsum $(TEST_FLAGS) ./local/e2e/compose ./local/e2e/container ./local/e2e/cli-only -- -count=1
4956

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ This Compose CLI tool makes it easy to run Docker containers and Docker Compose
1010
or Microsoft Azure Container Instances
1111
([ACI](https://azure.microsoft.com/services/container-instances))
1212
using the Docker commands you already know.
13+
14+
**Note: Compose CLI is released under the 1.x tag, until "Compose v2" gets a new home**
1315

14-
## Local Docker Compose
16+
## Compose v2 (a.k.a "Local Docker Compose")
1517

1618
The `docker compose` local command is meant to be the next major version for docker-compose, and it supports the same commands and flags, in order to be used as a drop-in replacement.
1719
[Here](https://github.com/docker/compose-cli/issues/1283) is a checklist of docker-compose commands and flags that are implemented in `docker compose`.
@@ -21,6 +23,8 @@ This `docker compose` local command :
2123
* is quicker and uses more parallelism to run multiple tasks in parallel. It also uses buildkit by default
2224
* includes additional commands, like `docker compose ls` to list current compose projects
2325

26+
**Note: Compose v2 is released under the 2.x tag, until "Compose v2" gets a new home**
27+
2428
## Getting started
2529

2630
To get started with Compose CLI, all you need is:

builder.Makefile

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ STATIC_FLAGS=CGO_ENABLED=0
2828

2929
GIT_TAG?=$(shell git describe --tags --match "v[0-9]*")
3030

31-
LDFLAGS="-s -w -X $(PKG_NAME)/internal.Version=${GIT_TAG} -X $(PKG_NAME)/internal.ComposePluginVersion=2.0.0-beta.2"
31+
LDFLAGS="-s -w -X $(PKG_NAME)/internal.Version=${GIT_TAG}"
3232
GO_BUILD=$(STATIC_FLAGS) go build -trimpath -ldflags=$(LDFLAGS)
3333

3434
BINARY?=bin/docker
@@ -45,40 +45,20 @@ ifdef BUILD_TAGS
4545
LINT_TAGS=--build-tags $(BUILD_TAGS)
4646
endif
4747

48-
TAR_TRANSFORM:=--transform s/packaging/docker/ --transform s/bin/docker/ \
49-
--transform s/docker-linux-amd64/docker/ --transform s/docker-linux-arm64/docker/ \
50-
--transform s/docker-linux-armv6/docker/ --transform s/docker-linux-armv7/docker/ \
51-
--transform s/docker-darwin-amd64/docker/ --transform s/docker-darwin-arm64/docker/ \
52-
--transform s/docker-compose-linux-amd64/docker-compose/ --transform s/docker-compose-linux-arm64/docker-compose/ \
53-
--transform s/docker-compose-linux-armv6/docker-compose/ --transform s/docker-compose-linux-armv7/docker-compose/ \
54-
--transform s/docker-compose-darwin-amd64/docker-compose/ --transform s/docker-compose-darwin-arm64/docker-compose/
55-
56-
ifneq ($(findstring bsd,$(shell tar --version)),)
57-
TAR_TRANSFORM=-s /packaging/docker/ -s /bin/docker/ \
58-
-s /docker-linux-amd64/docker/ -s /docker-linux-arm64/docker/ \
59-
-s /docker-linux-armv6/docker/ -s /docker-linux-armv7/docker/ \
60-
-s /docker-darwin-amd64/docker/ -s /docker-darwin-arm64/docker/ \
61-
-s /docker-compose-linux-amd64/docker-compose/ -s /docker-compose-linux-arm64/docker-compose/ \
62-
-s /docker-compose-linux-armv6/docker-compose/ -s /docker-compose-linux-armv7/docker-compose/ \
63-
-s /docker-compose-darwin-amd64/docker-compose/ -s /docker-compose-darwin-arm64/docker-compose/
64-
endif
65-
66-
all: cli
67-
6848
.PHONY: protos
6949
protos:
7050
protoc -I. --go_out=plugins=grpc,paths=source_relative:. ${PROTOS}
7151

7252
.PHONY: cli
73-
cli: compose-plugin
53+
cli:
7454
GOOS=${GOOS} GOARCH=${GOARCH} $(GO_BUILD) $(TAGS) -o $(BINARY_WITH_EXTENSION) ./cli
7555

7656
.PHONY: compose-plugin
7757
compose-plugin:
7858
GOOS=${GOOS} GOARCH=${GOARCH} $(GO_BUILD) $(TAGS) -o $(COMPOSE_BINARY_WITH_EXTENSION) .
7959

8060
.PHONY: cross
81-
cross: cross-compose-plugin
61+
cross:
8262
GOOS=linux GOARCH=amd64 $(GO_BUILD) $(TAGS) -o $(BINARY)-linux-amd64 ./cli
8363
GOOS=linux GOARCH=arm64 $(GO_BUILD) $(TAGS) -o $(BINARY)-linux-arm64 ./cli
8464
GOOS=linux GOARM=6 GOARCH=arm $(GO_BUILD) $(TAGS) -o $(BINARY)-linux-armv6 ./cli
@@ -117,20 +97,6 @@ check-license-headers:
11797
check-go-mod:
11898
./scripts/validate/check-go-mod
11999

120-
.PHONY: package
121-
package: cross
122-
mkdir -p dist
123-
tar -czf dist/docker-linux-amd64.tar.gz $(TAR_TRANSFORM) packaging/LICENSE $(BINARY)-linux-amd64 $(COMPOSE_BINARY)-linux-amd64
124-
tar -czf dist/docker-linux-arm64.tar.gz $(TAR_TRANSFORM) packaging/LICENSE $(BINARY)-linux-arm64 $(COMPOSE_BINARY)-linux-arm64
125-
tar -czf dist/docker-linux-armv6.tar.gz $(TAR_TRANSFORM) packaging/LICENSE $(BINARY)-linux-armv6 $(COMPOSE_BINARY)-linux-armv6
126-
tar -czf dist/docker-linux-armv7.tar.gz $(TAR_TRANSFORM) packaging/LICENSE $(BINARY)-linux-armv7 $(COMPOSE_BINARY)-linux-armv7
127-
tar -czf dist/docker-darwin-amd64.tar.gz $(TAR_TRANSFORM) packaging/LICENSE $(BINARY)-darwin-amd64 $(COMPOSE_BINARY)-darwin-amd64
128-
tar -czf dist/docker-darwin-arm64.tar.gz $(TAR_TRANSFORM) packaging/LICENSE $(BINARY)-darwin-arm64 $(COMPOSE_BINARY)-darwin-arm64
129-
cp $(BINARY)-windows-amd64.exe $(WORK_DIR)/docker.exe
130-
cp $(COMPOSE_BINARY)-windows-amd64.exe $(WORK_DIR)/docker-compose.exe
131-
rm -f dist/docker-windows-amd64.zip && zip dist/docker-windows-amd64.zip -j packaging/LICENSE $(WORK_DIR)/docker.exe $(WORK_DIR)/docker-compose.exe
132-
rm -r $(WORK_DIR)
133-
134100
.PHONY: yamldocs
135101
yamldocs:
136102
go run docs/yaml/main/generate.go

cli/cmd/compose/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func versionCommand() *cobra.Command {
5252
}
5353

5454
func runVersion(opts versionOptions) {
55-
displayedVersion := strings.TrimPrefix(internal.ComposePluginVersion, "v")
55+
displayedVersion := strings.TrimPrefix(internal.Version, "v")
5656
if opts.short {
5757
fmt.Println(displayedVersion)
5858
return

internal/variables.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,4 @@ const (
2626
var (
2727
// Version is the version of the CLI injected in compilation time
2828
Version = "dev"
29-
// ComposePluginVersion is the version of the compose cli plugin, injected in compilation time
30-
ComposePluginVersion = "dev"
3129
)

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ func main() {
5959
manager.Metadata{
6060
SchemaVersion: "0.1.0",
6161
Vendor: "Docker Inc.",
62-
Version: strings.TrimPrefix(internal.ComposePluginVersion, "v"),
62+
Version: strings.TrimPrefix(internal.Version, "v"),
6363
})
6464
}

0 commit comments

Comments
 (0)