From 4110389a85bef562e40ba095b7cf1494e4a330b7 Mon Sep 17 00:00:00 2001 From: Neri Marschik Date: Thu, 12 Jul 2018 13:18:22 +0900 Subject: [PATCH] Bump version to 0.5.0 Fix build process to work with Dockerhub --- Dockerfile | 23 +++++++++++++---------- Dockerfile.build | 9 --------- Makefile | 10 +++++----- 3 files changed, 18 insertions(+), 24 deletions(-) delete mode 100644 Dockerfile.build diff --git a/Dockerfile b/Dockerfile index 069481b..90e06d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,14 @@ -FROM alpine - -WORKDIR /root - -RUN apk update && apk add ca-certificates openssl && update-ca-certificates - -# download release of ecs-gen -ENV ECS_GEN_RELEASE 0.3.2 -RUN wget https://github.com/codesuki/ecs-gen/releases/download/$ECS_GEN_RELEASE/ecs-gen-linux-amd64.zip && unzip ecs-gen-linux-amd64.zip && cp ecs-gen-linux-amd64 /usr/local/bin/ecs-gen - +FROM golang:1.7.3-alpine AS builder +RUN apk update && apk add --no-cache git make +WORKDIR /go/src/github.com/codesuki/ecs-gen +COPY glide.lock glide.yaml Makefile /go/src/github.com/codesuki/ecs-gen/ +# to statically link +ENV CGO_ENABLED 0 +RUN go get -u github.com/Masterminds/glide && make deps +COPY . . +RUN make build + +FROM alpine:3.8 +RUN apk update && apk add --no-cache ca-certificates openssl && update-ca-certificates +COPY --from=builder /go/src/github.com/codesuki/ecs-gen/build/ecs-gen-linux-amd64 /usr/bin/ecs-gen CMD ["ecs-gen"] diff --git a/Dockerfile.build b/Dockerfile.build deleted file mode 100644 index 2c963cb..0000000 --- a/Dockerfile.build +++ /dev/null @@ -1,9 +0,0 @@ -FROM golang:1.7.3-alpine - -RUN apk update && apk add git make - -WORKDIR /go/src/github.com/codesuki/ecs-gen - -# to statically link -ENV CGO_ENABLED 0 -CMD go get -u github.com/Masterminds/glide && make build diff --git a/Makefile b/Makefile index a7ba7df..3a30e1c 100644 --- a/Makefile +++ b/Makefile @@ -5,18 +5,18 @@ WORKDIR = /go/src/github.com/codesuki/ecs-gen LDFLAGS = -X main.version=$(VERSION) -.PHONY: docker build clean deps +.PHONY: docker build clean deps zip docker: - docker build -t ecs-gen-builder:latest -f Dockerfile.build . - docker run --rm -v $(CURDIR):$(WORKDIR) ecs-gen-builder - docker build -t ecs-gen:latest -f Dockerfile . + docker build --target builder -t ecs-gen:latest . + docker run -v $(CURDIR)/build:/mnt/build --rm ecs-gen:latest cp -R $(WORKDIR)/build/ /mnt/ + docker build -t ecs-gen:latest . docker run --rm ecs-gen:latest ecs-gen --version build: deps for GOOS in darwin linux; do \ for GOARCH in 386 amd64; do \ - GOOS=$$GOOS GOARCH=$$GOARCH go build -ldflags "$(LDFLAGS)" -v -o build/$(NAME)-$$GOOS-$$GOARCH ; \ + GOOS=$$GOOS GOARCH=$$GOARCH go build -ldflags "$(LDFLAGS)" -o build/$(NAME)-$$GOOS-$$GOARCH ; \ done \ done