From 4be356245048c6b7d13fd4eaed5a79dacffe2e71 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Wed, 10 Jun 2020 10:51:52 +0200 Subject: [PATCH] Revert "Refactor build process to build in containers" This reverts commit adab0d1bdf7bf2cc242128aae7f5044bd5182ea1. Signed-off-by: Nicolas De Loof --- ecs/Dockerfile | 32 -------------------------------- ecs/Makefile | 37 +++++++------------------------------ ecs/builder.Makefile | 39 --------------------------------------- 3 files changed, 7 insertions(+), 101 deletions(-) delete mode 100644 ecs/Dockerfile delete mode 100644 ecs/builder.Makefile diff --git a/ecs/Dockerfile b/ecs/Dockerfile deleted file mode 100644 index db374fb8b..000000000 --- a/ecs/Dockerfile +++ /dev/null @@ -1,32 +0,0 @@ -# syntax = docker/dockerfile:experimental -ARG GO_VERSION=1.14.2 - -FROM golang:${GO_VERSION} AS base -ARG TARGET_OS=unknown -ARG TARGET_ARCH=unknown -ARG PWD=/ecs-plugin -ENV GO111MODULE=on - -WORKDIR ${PWD} -ADD go.* ${PWD} -RUN go mod download -ADD . ${PWD} - -FROM base AS make-plugin -RUN --mount=type=cache,target=/root/.cache/go-build \ - GOOS=${TARGET_OS} \ - GOARCH=${TARGET_ARCH} \ - make -f builder.Makefile build - -FROM base AS make-cross -RUN --mount=type=cache,target=/root/.cache/go-build \ - make -f builder.Makefile cross - -FROM scratch AS build -COPY --from=make-plugin /ecs-plugin/dist/* . - -FROM scratch AS cross -COPY --from=make-cross /ecs-plugin/dist/* . - -FROM base as test -RUN make -f builder.Makefile test diff --git a/ecs/Makefile b/ecs/Makefile index c5fe28758..0fd6b65ae 100644 --- a/ecs/Makefile +++ b/ecs/Makefile @@ -1,27 +1,11 @@ -GOOS ?= $(shell go env GOOS) -GOARCH ?= $(shell go env GOARCH) -PWD = $(shell pwd) +clean: + rm -rf dist/ -export DOCKER_BUILDKIT=1 - -.DEFAULT_GOAL := build - -build: ## Build for the current - @docker build . \ - --output type=local,dest=./dist \ - --build-arg TARGET_OS=${GOOS} \ - --build-arg TARGET_ARCH=${GOARCH} \ - --target build - -cross: ## Cross build for linux, macos and windows - @docker build . \ - --output type=local,dest=./dist \ - --target cross +build: + go build -v -o dist/docker-ecs cmd/main/main.go test: build ## Run tests - @docker build . \ - --output type=local,dest=./dist \ - --target test + go test ./... -v e2e: build ## Run tests go test ./... -v -tags=e2e @@ -31,13 +15,6 @@ dev: build ln -f -s "${PWD}/dist/docker-ecs" "${HOME}/.docker/cli-plugins/docker-ecs" lint: ## Verify Go files - @docker run --rm -t \ - -v $(PWD):/app \ - -w /app \ - golangci/golangci-lint:v1.27-alpine \ - golangci-lint run --timeout 10m0s --config ./golangci.yaml ./... + golangci-lint run --config ./golangci.yaml ./... -clean: - rm -rf dist/ - -.PHONY: clean build test dev lint e2e cross +.PHONY: clean build test dev lint e2e diff --git a/ecs/builder.Makefile b/ecs/builder.Makefile deleted file mode 100644 index 81145e029..000000000 --- a/ecs/builder.Makefile +++ /dev/null @@ -1,39 +0,0 @@ -GOOS ?= $(shell go env GOOS) -GOARCH ?= $(shell go env GOARCH) - -PROTOS=$(shell find . -name \*.proto) - -EXTENSION := -ifeq ($(GOOS),windows) - EXTENSION := .exe -endif - -STATIC_FLAGS= CGO_ENABLED=0 -LDFLAGS := "-s -w" -GO_BUILD = $(STATIC_FLAGS) go build -trimpath -ldflags=$(LDFLAGS) - -BINARY=dist/docker-ecs -BINARY_WITH_EXTENSION=$(BINARY)$(EXTENSION) - -export DOCKER_BUILDKIT=1 - -all: build - -clean: - rm -rf dist/ - -build: - $(GO_BUILD) -v -o $(BINARY_WITH_EXTENSION) cmd/main/main.go - -cross: - @GOOS=linux GOARCH=amd64 $(GO_BUILD) -v -o $(BINARY)-linux-amd64 cmd/main/main.go - @GOOS=darwin GOARCH=amd64 $(GO_BUILD) -v -o $(BINARY)-darwin-amd64 cmd/main/main.go - @GOOS=windows GOARCH=amd64 $(GO_BUILD) -v -o $(BINARY)-windows-amd64.exe cmd/main/main.go - -test: build ## Run tests - @go test ./... -v - -lint: ## Verify Go files - golangci-lint run --timeout 10m0s --config ./golangci.yaml ./... - -.PHONY: clean build test dev lint e2e