diff --git a/.gitignore b/.gitignore index 7d687818842c..b61aac972a46 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ .idea/ .DS_Store vendor/ -dist/ \ No newline at end of file +dist/ diff --git a/Dockerfile-apiserver b/Dockerfile-apiserver new file mode 100644 index 000000000000..3066a5fd7f7c --- /dev/null +++ b/Dockerfile-apiserver @@ -0,0 +1,5 @@ +FROM debian:9.1 + +COPY dist/argo-apiserver /bin/ + +ENTRYPOINT [ "/bin/argo-apiserver" ] diff --git a/Makefile b/Makefile index 2a087e352ece..ba0bbaafe6fe 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,6 @@ PACKAGE=github.com/argoproj/argo BUILD_DIR=${GOPATH}/src/${PACKAGE} DIST_DIR=${GOPATH}/src/${PACKAGE}/dist CURRENT_DIR=$(shell pwd) -BUILD_DIR_LINK=$(shell readlink ${BUILD_DIR}) VERSION=$(shell cat ${BUILD_DIR}/VERSION) COMMIT=$(shell git rev-parse HEAD) @@ -14,53 +13,59 @@ BRANCH=$(shell git rev-parse --abbrev-ref HEAD) LDFLAGS = -ldflags "-X ${PACKAGE}.Version=${VERSION} -X ${PACKAGE}.Revision=${COMMIT} -X ${PACKAGE}.Branch=${BRANCH}" +BUILDER_IMAGE=argo-builder +BUILDER_CMD=docker run --rm -v ${BUILD_DIR}:/root/go/src/${PACKAGE} -w /root/go/src/${PACKAGE} ${BUILDER_IMAGE} + # Build the project -all: lint cli-linux cli-darwin workflow workflow-image +all: lint cli-linux cli-darwin workflow workflow-image apiserver builder: cd ${BUILD_DIR}; \ - docker build -t argo-builder -f Dockerfile-builder . ; \ + docker build -t ${BUILDER_IMAGE} -f Dockerfile-builder . ; \ cd - >/dev/null cli: cd ${BUILD_DIR}; \ - go build -i ${LDFLAGS} -o ${DIST_DIR}/argo ./cli ; \ + go build -v -i ${LDFLAGS} -o ${DIST_DIR}/argo ./cli ; \ cd - >/dev/null cli-linux: builder rm -f ${DIST_DIR}/argocli/linux-amd64/argo - docker run --rm -v ${BUILD_DIR}:/root/go/src/${PACKAGE} -w /root/go/src/${PACKAGE} argo-builder make cli + ${BUILDER_CMD} make cli mkdir -p ${DIST_DIR}/argocli/linux-amd64 mv ${DIST_DIR}/argo ${DIST_DIR}/argocli/linux-amd64/argo cli-darwin: cd ${BUILD_DIR}; \ - GOOS=darwin GOARCH=${GOARCH} go build ${LDFLAGS} -o ${DIST_DIR}/argocli/darwin-amd64/argo ./cli ; \ + GOOS=darwin GOARCH=${GOARCH} go build -v ${LDFLAGS} -o ${DIST_DIR}/argocli/${GOOS}-${GOARCH}/argo ./cli ; \ + cd - >/dev/null + +apiserver: + cd ${BUILD_DIR}; \ + go build -i ${LDFLAGS} -o ${DIST_DIR}/argo-apiserver ./apiserver ; \ + cd - >/dev/null + +apiserver-linux: builder + ${BUILDER_CMD} make apiserver + +apiserver-image: apiserver-linux + cd ${BUILD_DIR}; \ + docker build -f Dockerfile-apiserver . ; \ cd - >/dev/null workflow: cd ${BUILD_DIR}; \ - go build -i ${LDFLAGS} -o ${DIST_DIR}/workflow-controller ./workflow ; \ + go build -v -i ${LDFLAGS} -o ${DIST_DIR}/workflow-controller ./workflow ; \ cd - >/dev/null workflow-linux: builder - docker run --rm -v ${BUILD_DIR}:/root/go/src/${PACKAGE} -w /root/go/src/${PACKAGE} argo-builder make workflow + ${BUILDER_CMD} make workflow -workflow-image: workflow +workflow-image: workflow-linux cd ${BUILD_DIR}; \ docker build -f Dockerfile-workflow-controller . ; \ cd - >/dev/null -link: - BUILD_DIR=${BUILD_DIR}; \ - BUILD_DIR_LINK=${BUILD_DIR_LINK}; \ - CURRENT_DIR=${CURRENT_DIR}; \ - if [ "$${BUILD_DIR_LINK}" != "$${CURRENT_DIR}" ]; then \ - echo "Fixing symlinks for build"; \ - rm -f $${BUILD_DIR}; \ - ln -s $${CURRENT_DIR} $${BUILD_DIR}; \ - fi - test: if ! hash go2xunit 2>/dev/null; then go install github.com/tebeka/go2xunit; fi cd ${BUILD_DIR}; \ @@ -80,4 +85,4 @@ fmt: clean: -rm -rf ${BUILD_DIR}/dist -.PHONY: builder cli cli-linux cli-darwin workflow workflow-image lint test fmt clean \ No newline at end of file +.PHONY: builder cli cli-linux cli-darwin workflow workflow-image apiserver lint test fmt clean diff --git a/apiserver/cmd/root.go b/apiserver/cmd/root.go new file mode 100644 index 000000000000..4a0d2107a7ea --- /dev/null +++ b/apiserver/cmd/root.go @@ -0,0 +1,14 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +// RootCmd is the argo root level command +var RootCmd = &cobra.Command{ + Use: "argo-apiserver", + Short: "Argo API Server", + Run: func(cmd *cobra.Command, args []string) { + cmd.HelpFunc()(cmd, args) + }, +} diff --git a/apiserver/cmd/version.go b/apiserver/cmd/version.go new file mode 100644 index 000000000000..cff700ae2344 --- /dev/null +++ b/apiserver/cmd/version.go @@ -0,0 +1,25 @@ +package cmd + +import ( + "fmt" + + "github.com/argoproj/argo" + "github.com/spf13/cobra" +) + +const ( + // CLIName is the name of the CLI + CLIName = "argo-apiserver" +) + +func init() { + RootCmd.AddCommand(versionCmd) +} + +var versionCmd = &cobra.Command{ + Use: "version", + Short: fmt.Sprintf("Print version information"), + Run: func(cmd *cobra.Command, args []string) { + fmt.Printf("%s version %s\n", CLIName, argo.FullVersion) + }, +} diff --git a/apiserver/main.go b/apiserver/main.go new file mode 100644 index 000000000000..83a8813ce695 --- /dev/null +++ b/apiserver/main.go @@ -0,0 +1,26 @@ +// Copyright 2015-2017 Applatix, Inc. All rights reserved. +package main + +import ( + "fmt" + "os" + + "github.com/argoproj/argo/apiserver/cmd" + "github.com/spf13/cobra" +) + +// RootCmd is the argo root level command +var RootCmd = &cobra.Command{ + Use: "argo-apiserver", + Short: "Argo API Server", + Run: func(cmd *cobra.Command, args []string) { + cmd.HelpFunc()(cmd, args) + }, +} + +func main() { + if err := cmd.RootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } +} diff --git a/cli/main.go b/cli/main.go index 8d1a54a02f67..a962de744511 100644 --- a/cli/main.go +++ b/cli/main.go @@ -1,4 +1,3 @@ -// Copyright 2015-2017 Applatix, Inc. All rights reserved. package main import (