From 4ddff5bb251df9426682f5378fc4444e3cfbc322 Mon Sep 17 00:00:00 2001 From: davidnewhall2 Date: Thu, 26 Dec 2019 20:57:01 -0800 Subject: [PATCH] go all the way --- .metadata.sh | 8 ++------ Makefile | 2 -- init/docker/Dockerfile | 17 +++++------------ init/docker/hooks/build | 1 - init/homebrew/service.rb.tmpl | 10 +++------- 5 files changed, 10 insertions(+), 28 deletions(-) diff --git a/.metadata.sh b/.metadata.sh index 5c380efc..42b73a6c 100755 --- a/.metadata.sh +++ b/.metadata.sh @@ -25,10 +25,8 @@ export BINARY GHUSER HBREPO MAINT VENDOR DESC GOLANGCI_LINT_ARGS CONFIG_FILE LIC # Fix the repo if it doesn't match the binary name. # Provide a better URL if one exists. -# Used as go import path in docker and homebrew builds. -IMPORT_PATH="github.com/${GHUSER}/${BINARY}" # Used for source links and wiki links. -SOURCE_URL="https://${IMPORT_PATH}" +SOURCE_URL="https://github.com/${GHUSER}/${BINARY}" # Used for documentation links. URL="${SOURCE_URL}" @@ -40,9 +38,7 @@ ITERATION=$(git rev-list --count --all || echo 0) DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" COMMIT="$(git rev-parse --short HEAD || echo 0)" -# Used by homebrew downloads. -#SOURCE_PATH=https://codeload.${IMPORT_PATH}/tar.gz/v${VERSION} # This is a custom download path for homebrew formula. SOURCE_PATH=https://golift.io/${BINARY}/archive/v${VERSION}.tar.gz -export IMPORT_PATH SOURCE_URL URL VVERSION VERSION ITERATION DATE COMMIT SOURCE_PATH +export SOURCE_URL URL VVERSION VERSION ITERATION DATE COMMIT SOURCE_PATH diff --git a/Makefile b/Makefile index 609141b6..0214ea0d 100644 --- a/Makefile +++ b/Makefile @@ -231,7 +231,6 @@ docker: --build-arg "VENDOR=$(VENDOR)" \ --build-arg "AUTHOR=$(MAINT)" \ --build-arg "BINARY=$(BINARY)" \ - --build-arg "IMPORT_PATH=$(IMPORT_PATH)" \ --build-arg "SOURCE_URL=$(SOURCE_URL)" \ --build-arg "CONFIG_FILE=$(CONFIG_FILE)" \ --tag $(BINARY) . @@ -250,7 +249,6 @@ $(BINARY).rb: v$(VERSION).tar.gz.sha256 init/homebrew/$(FORMULA).rb.tmpl -e "s/{{SHA256}}/$(shell head -c64 $<)/g" \ -e "s/{{Desc}}/$(DESC)/g" \ -e "s%{{URL}}%$(URL)%g" \ - -e "s%{{IMPORT_PATH}}%$(IMPORT_PATH)%g" \ -e "s%{{SOURCE_PATH}}%$(SOURCE_PATH)%g" \ -e "s%{{SOURCE_URL}}%$(SOURCE_URL)%g" \ -e "s%{{CONFIG_FILE}}%$(CONFIG_FILE)%g" \ diff --git a/init/docker/Dockerfile b/init/docker/Dockerfile index cdfeef05..2b74c41e 100644 --- a/init/docker/Dockerfile +++ b/init/docker/Dockerfile @@ -9,21 +9,15 @@ ARG BUILD_DATE=0 ARG COMMIT=0 ARG VERSION=unknown ARG BINARY=application-builder -ARG IMPORT_PATH=github.com/golift/application-builder FROM golang:stretch as builder ARG ARCH ARG OS ARG BINARY -ARG IMPORT_PATH -RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin $GOPATH/src/${IMPORT_PATH} -RUN apt-get update \ - && apt-get install -y curl \ - && curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh - -COPY . $GOPATH/src/${IMPORT_PATH} -WORKDIR $GOPATH/src/${IMPORT_PATH} +RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin $GOPATH/src /${BINARY} +COPY . /${BINARY} +WORKDIR /${BINARY} RUN go mod vendor \ && CGO_ENABLED=0 make ${BINARY}.${ARCH}.${OS} @@ -36,7 +30,6 @@ ARG COMMIT ARG VERSION ARG LICENSE=MIT ARG BINARY -ARG IMPORT_PATH ARG SOURCE_URL=http://github.com/golift/application-builder ARG URL=http://github.com/golift/application-builder ARG DESC=application-builder @@ -58,8 +51,8 @@ LABEL org.opencontainers.image.created="${BUILD_DATE}" \ org.opencontainers.image.licenses="${LICENSE}" \ org.opencontainers.image.version="${VERSION}" -COPY --from=builder /go/src/${IMPORT_PATH}/${BINARY}.${ARCH}.${OS} /image -COPY --from=builder /go/src/${IMPORT_PATH}/examples/${CONFIG_FILE}.example /etc/${BINARY}/${CONFIG_FILE} +COPY --from=builder /${BINARY}/${BINARY}.${ARCH}.${OS} /image +COPY --from=builder /${BINARY}/examples/${CONFIG_FILE}.example /etc/${BINARY}/${CONFIG_FILE} COPY --from=builder /etc/ssl /etc/ssl VOLUME [ "/etc/${BINARY}" ] diff --git a/init/docker/hooks/build b/init/docker/hooks/build index 3eb4e50e..c8f2796f 100755 --- a/init/docker/hooks/build +++ b/init/docker/hooks/build @@ -28,7 +28,6 @@ for build in $BUILDS; do --build-arg "VENDOR=${VENDOR}" \ --build-arg "AUTHOR=${MAINT}" \ --build-arg "BINARY=${BINARY}" \ - --build-arg "IMPORT_PATH=${IMPORT_PATH}" \ --build-arg "SOURCE_URL=${SOURCE_URL}" \ --build-arg "CONFIG_FILE=${CONFIG_FILE}" \ --tag "${IMAGE_NAME}_${os}_${name}" \ diff --git a/init/homebrew/service.rb.tmpl b/init/homebrew/service.rb.tmpl index ff8802d9..cb10dcb2 100644 --- a/init/homebrew/service.rb.tmpl +++ b/init/homebrew/service.rb.tmpl @@ -1,7 +1,6 @@ # Homebrew Formula Template. Built by Makefile: `make fomula` # This is part of Application Builder. # https://github.com/golift/application-builder -# This file is used when FORMULA is set to 'service'. class {{Class}} < Formula desc "{{Desc}}" homepage "{{URL}}" @@ -13,14 +12,11 @@ class {{Class}} < Formula depends_on "dep" def install - ENV["GOPATH"] = buildpath - - bin_path = buildpath/"src/{{IMPORT_PATH}}" - # Copy all files from their current location (GOPATH root) - # to $GOPATH/src/{{IMPORT_PATH}} + bin_path = buildpath/"#{name}" + # Copy all files from their current location to buildpath/#{name} bin_path.install Dir["*",".??*"] cd bin_path do - system "dep", "ensure", "--vendor-only" + system "make" "vendor" system "make", "install", "VERSION=#{version}", "ITERATION={{Iter}}", "PREFIX=#{prefix}", "ETC=#{etc}" # If this fails, the user gets a nice big warning about write permissions on their # #{var}/log folder. The alternative could be letting the app silently fail