Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Add a new binary docker-app-standalone which is in fact the old docke…
Browse files Browse the repository at this point in the history
…r-app before its pluginization.

Added it to cross compilation
Now each released tar.gz file per os comes with two binaries in it: docker-app-plugin-os and docker-app-standalone-os

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
  • Loading branch information
silvin-lubecki committed Feb 26, 2019
1 parent 2452b40 commit 4697791
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 4 deletions.
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,22 @@ check_go_env:
@test $$(go list) = "$(PKG_NAME)" || \
(echo "Invalid Go environment - The local directory structure must match: $(PKG_NAME)" && false)

cross: bin/$(BIN_NAME)-linux bin/$(BIN_NAME)-darwin bin/$(BIN_NAME)-windows.exe ## cross-compile binaries (linux, darwin, windows)
cross: cross-plugin cross-standalone ## cross-compile binaries (linux, darwin, windows)

cross-plugin: bin/$(BIN_NAME)-linux bin/$(BIN_NAME)-darwin bin/$(BIN_NAME)-windows.exe

cross-standalone: bin/${BIN_STANDALONE_NAME}-linux bin/${BIN_STANDALONE_NAME}-darwin bin/${BIN_STANDALONE_NAME}-windows.exe

e2e-cross: bin/$(BIN_NAME)-e2e-linux bin/$(BIN_NAME)-e2e-darwin bin/$(BIN_NAME)-e2e-windows.exe

.PHONY: bin/${BIN_STANDALONE_NAME}-windows
bin/${BIN_STANDALONE_NAME}-%.exe bin/${BIN_STANDALONE_NAME}-%: cmd/${BIN_STANDALONE_NAME} check_go_env
GOOS=$* $(GO_BUILD) -o $@ ./$<

.PHONY: bin/${BIN_STANDALONE_NAME}
bin/${BIN_STANDALONE_NAME}: cmd/${BIN_STANDALONE_NAME} check_go_env
$(GO_BUILD) -o $@$(EXEC_EXT) ./$<

.PHONY: bin/$(BIN_NAME)-e2e-windows
bin/$(BIN_NAME)-e2e-%.exe bin/$(BIN_NAME)-e2e-%: e2e bin/$(BIN_NAME)-%
GOOS=$* $(GO_TEST) -c -o $@ ./e2e/
Expand Down
53 changes: 53 additions & 0 deletions cmd/docker-app-standalone/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package main

import (
"fmt"
"os"

"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/docker/app/internal"
app "github.com/docker/app/internal/commands"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
cliflags "github.com/docker/cli/cli/flags"
"github.com/sirupsen/logrus"
)

func main() {
dockerCli, err := command.NewDockerCli()
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
logrus.SetOutput(dockerCli.Err())

cmd := app.NewRootCmd()
configureRootCmd(cmd, dockerCli)

if err := cmd.Execute(); err != nil {
os.Exit(1)
}
}

func configureRootCmd(cmd *cobra.Command, dockerCli *command.DockerCli) {
var (
opts *cliflags.ClientOptions
flags *pflag.FlagSet
)

cmd.Use = "docker-app"
cmd.SilenceUsage = true
cmd.TraverseChildren = true
cmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
opts.Common.SetDefaultOptions(flags)
return dockerCli.Initialize(opts)
}
cmd.Version = fmt.Sprintf("%s, build %s", internal.Version, internal.GitCommit)

opts, flags, _ = cli.SetupRootCommand(cmd)
flags.BoolP("version", "v", false, "Print version information")
cmd.SetVersionTemplate("docker-app version {{.Version}}\n")

app.AddCommands(cmd, dockerCli)
}
12 changes: 9 additions & 3 deletions docker.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ cross: create_bin ## cross-compile binaries (linux, darwin, windows)
docker cp $(CROSS_CTNR_NAME):$(PKG_PATH)/bin/$(BIN_NAME)-linux bin/$(BIN_NAME)-linux
docker cp $(CROSS_CTNR_NAME):$(PKG_PATH)/bin/$(BIN_NAME)-darwin bin/$(BIN_NAME)-darwin
docker cp $(CROSS_CTNR_NAME):$(PKG_PATH)/bin/$(BIN_NAME)-windows.exe bin/$(BIN_NAME)-windows.exe
docker cp $(CROSS_CTNR_NAME):$(PKG_PATH)/bin/${BIN_STANDALONE_NAME}-linux bin/${BIN_STANDALONE_NAME}-linux
docker cp $(CROSS_CTNR_NAME):$(PKG_PATH)/bin/${BIN_STANDALONE_NAME}-darwin bin/${BIN_STANDALONE_NAME}-darwin
docker cp $(CROSS_CTNR_NAME):$(PKG_PATH)/bin/${BIN_STANDALONE_NAME}-windows.exe bin/${BIN_STANDALONE_NAME}-windows.exe
docker rm $(CROSS_CTNR_NAME)
@$(call chmod,+x,bin/$(BIN_NAME)-linux)
@$(call chmod,+x,bin/$(BIN_NAME)-darwin)
@$(call chmod,+x,bin/$(BIN_NAME)-windows.exe)
@$(call chmod,+x,bin/${BIN_STANDALONE_NAME}-linux)
@$(call chmod,+x,bin/${BIN_STANDALONE_NAME}-darwin)
@$(call chmod,+x,bin/${BIN_STANDALONE_NAME}-windows.exe)

cli-cross: create_bin
docker build $(BUILD_ARGS) --target=build -t $(CLI_IMAGE_NAME) .
Expand All @@ -71,11 +77,11 @@ e2e-cross: create_bin
@$(call chmod,+x,bin/$(BIN_NAME)-e2e-windows.exe)

tars:
tar czf bin/$(BIN_NAME)-linux.tar.gz -C bin $(BIN_NAME)-linux
tar --transform='flags=r;s|$(BIN_NAME)-linux|$(BIN_NAME)-plugin-linux|' -czf bin/$(BIN_NAME)-linux.tar.gz -C bin $(BIN_NAME)-linux ${BIN_STANDALONE_NAME}-linux
tar czf bin/$(BIN_NAME)-e2e-linux.tar.gz -C bin $(BIN_NAME)-e2e-linux
tar czf bin/$(BIN_NAME)-darwin.tar.gz -C bin $(BIN_NAME)-darwin
tar --transform='flags=r;s|$(BIN_NAME)-darwin|$(BIN_NAME)-plugin-darwin|' -czf bin/$(BIN_NAME)-darwin.tar.gz -C bin $(BIN_NAME)-darwin ${BIN_STANDALONE_NAME}-darwin
tar czf bin/$(BIN_NAME)-e2e-darwin.tar.gz -C bin $(BIN_NAME)-e2e-darwin
tar czf bin/$(BIN_NAME)-windows.tar.gz -C bin $(BIN_NAME)-windows.exe
tar --transform='flags=r;s|$(BIN_NAME)-windows|$(BIN_NAME)-plugin-windows|' -czf bin/$(BIN_NAME)-windows.tar.gz -C bin $(BIN_NAME)-windows.exe ${BIN_STANDALONE_NAME}-windows.exe
tar czf bin/$(BIN_NAME)-e2e-windows.tar.gz -C bin $(BIN_NAME)-e2e-windows.exe

test: test-unit test-e2e ## run all tests
Expand Down
1 change: 1 addition & 0 deletions vars.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PKG_NAME := github.com/docker/app
BIN_NAME ?= docker-app
BIN_STANDALONE_NAME := ${BIN_NAME}-standalone
E2E_NAME := $(BIN_NAME)-e2e

# Enable experimental features. "on" or "off"
Expand Down

0 comments on commit 4697791

Please sign in to comment.