go all the way
This commit is contained in:
parent
3cf7d89363
commit
4ddff5bb25
|
|
@ -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.
|
# Fix the repo if it doesn't match the binary name.
|
||||||
# Provide a better URL if one exists.
|
# 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.
|
# Used for source links and wiki links.
|
||||||
SOURCE_URL="https://${IMPORT_PATH}"
|
SOURCE_URL="https://github.com/${GHUSER}/${BINARY}"
|
||||||
# Used for documentation links.
|
# Used for documentation links.
|
||||||
URL="${SOURCE_URL}"
|
URL="${SOURCE_URL}"
|
||||||
|
|
||||||
|
|
@ -40,9 +38,7 @@ ITERATION=$(git rev-list --count --all || echo 0)
|
||||||
DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||||
COMMIT="$(git rev-parse --short HEAD || echo 0)"
|
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.
|
# This is a custom download path for homebrew formula.
|
||||||
SOURCE_PATH=https://golift.io/${BINARY}/archive/v${VERSION}.tar.gz
|
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
|
||||||
|
|
|
||||||
2
Makefile
2
Makefile
|
|
@ -231,7 +231,6 @@ docker:
|
||||||
--build-arg "VENDOR=$(VENDOR)" \
|
--build-arg "VENDOR=$(VENDOR)" \
|
||||||
--build-arg "AUTHOR=$(MAINT)" \
|
--build-arg "AUTHOR=$(MAINT)" \
|
||||||
--build-arg "BINARY=$(BINARY)" \
|
--build-arg "BINARY=$(BINARY)" \
|
||||||
--build-arg "IMPORT_PATH=$(IMPORT_PATH)" \
|
|
||||||
--build-arg "SOURCE_URL=$(SOURCE_URL)" \
|
--build-arg "SOURCE_URL=$(SOURCE_URL)" \
|
||||||
--build-arg "CONFIG_FILE=$(CONFIG_FILE)" \
|
--build-arg "CONFIG_FILE=$(CONFIG_FILE)" \
|
||||||
--tag $(BINARY) .
|
--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/{{SHA256}}/$(shell head -c64 $<)/g" \
|
||||||
-e "s/{{Desc}}/$(DESC)/g" \
|
-e "s/{{Desc}}/$(DESC)/g" \
|
||||||
-e "s%{{URL}}%$(URL)%g" \
|
-e "s%{{URL}}%$(URL)%g" \
|
||||||
-e "s%{{IMPORT_PATH}}%$(IMPORT_PATH)%g" \
|
|
||||||
-e "s%{{SOURCE_PATH}}%$(SOURCE_PATH)%g" \
|
-e "s%{{SOURCE_PATH}}%$(SOURCE_PATH)%g" \
|
||||||
-e "s%{{SOURCE_URL}}%$(SOURCE_URL)%g" \
|
-e "s%{{SOURCE_URL}}%$(SOURCE_URL)%g" \
|
||||||
-e "s%{{CONFIG_FILE}}%$(CONFIG_FILE)%g" \
|
-e "s%{{CONFIG_FILE}}%$(CONFIG_FILE)%g" \
|
||||||
|
|
|
||||||
|
|
@ -9,21 +9,15 @@ ARG BUILD_DATE=0
|
||||||
ARG COMMIT=0
|
ARG COMMIT=0
|
||||||
ARG VERSION=unknown
|
ARG VERSION=unknown
|
||||||
ARG BINARY=application-builder
|
ARG BINARY=application-builder
|
||||||
ARG IMPORT_PATH=github.com/golift/application-builder
|
|
||||||
|
|
||||||
FROM golang:stretch as builder
|
FROM golang:stretch as builder
|
||||||
ARG ARCH
|
ARG ARCH
|
||||||
ARG OS
|
ARG OS
|
||||||
ARG BINARY
|
ARG BINARY
|
||||||
ARG IMPORT_PATH
|
|
||||||
|
|
||||||
RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin $GOPATH/src/${IMPORT_PATH}
|
RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin $GOPATH/src /${BINARY}
|
||||||
RUN apt-get update \
|
COPY . /${BINARY}
|
||||||
&& apt-get install -y curl \
|
WORKDIR /${BINARY}
|
||||||
&& curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
|
||||||
|
|
||||||
COPY . $GOPATH/src/${IMPORT_PATH}
|
|
||||||
WORKDIR $GOPATH/src/${IMPORT_PATH}
|
|
||||||
|
|
||||||
RUN go mod vendor \
|
RUN go mod vendor \
|
||||||
&& CGO_ENABLED=0 make ${BINARY}.${ARCH}.${OS}
|
&& CGO_ENABLED=0 make ${BINARY}.${ARCH}.${OS}
|
||||||
|
|
@ -36,7 +30,6 @@ ARG COMMIT
|
||||||
ARG VERSION
|
ARG VERSION
|
||||||
ARG LICENSE=MIT
|
ARG LICENSE=MIT
|
||||||
ARG BINARY
|
ARG BINARY
|
||||||
ARG IMPORT_PATH
|
|
||||||
ARG SOURCE_URL=http://github.com/golift/application-builder
|
ARG SOURCE_URL=http://github.com/golift/application-builder
|
||||||
ARG URL=http://github.com/golift/application-builder
|
ARG URL=http://github.com/golift/application-builder
|
||||||
ARG DESC=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.licenses="${LICENSE}" \
|
||||||
org.opencontainers.image.version="${VERSION}"
|
org.opencontainers.image.version="${VERSION}"
|
||||||
|
|
||||||
COPY --from=builder /go/src/${IMPORT_PATH}/${BINARY}.${ARCH}.${OS} /image
|
COPY --from=builder /${BINARY}/${BINARY}.${ARCH}.${OS} /image
|
||||||
COPY --from=builder /go/src/${IMPORT_PATH}/examples/${CONFIG_FILE}.example /etc/${BINARY}/${CONFIG_FILE}
|
COPY --from=builder /${BINARY}/examples/${CONFIG_FILE}.example /etc/${BINARY}/${CONFIG_FILE}
|
||||||
COPY --from=builder /etc/ssl /etc/ssl
|
COPY --from=builder /etc/ssl /etc/ssl
|
||||||
|
|
||||||
VOLUME [ "/etc/${BINARY}" ]
|
VOLUME [ "/etc/${BINARY}" ]
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ for build in $BUILDS; do
|
||||||
--build-arg "VENDOR=${VENDOR}" \
|
--build-arg "VENDOR=${VENDOR}" \
|
||||||
--build-arg "AUTHOR=${MAINT}" \
|
--build-arg "AUTHOR=${MAINT}" \
|
||||||
--build-arg "BINARY=${BINARY}" \
|
--build-arg "BINARY=${BINARY}" \
|
||||||
--build-arg "IMPORT_PATH=${IMPORT_PATH}" \
|
|
||||||
--build-arg "SOURCE_URL=${SOURCE_URL}" \
|
--build-arg "SOURCE_URL=${SOURCE_URL}" \
|
||||||
--build-arg "CONFIG_FILE=${CONFIG_FILE}" \
|
--build-arg "CONFIG_FILE=${CONFIG_FILE}" \
|
||||||
--tag "${IMAGE_NAME}_${os}_${name}" \
|
--tag "${IMAGE_NAME}_${os}_${name}" \
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
# Homebrew Formula Template. Built by Makefile: `make fomula`
|
# Homebrew Formula Template. Built by Makefile: `make fomula`
|
||||||
# This is part of Application Builder.
|
# This is part of Application Builder.
|
||||||
# https://github.com/golift/application-builder
|
# https://github.com/golift/application-builder
|
||||||
# This file is used when FORMULA is set to 'service'.
|
|
||||||
class {{Class}} < Formula
|
class {{Class}} < Formula
|
||||||
desc "{{Desc}}"
|
desc "{{Desc}}"
|
||||||
homepage "{{URL}}"
|
homepage "{{URL}}"
|
||||||
|
|
@ -13,14 +12,11 @@ class {{Class}} < Formula
|
||||||
depends_on "dep"
|
depends_on "dep"
|
||||||
|
|
||||||
def install
|
def install
|
||||||
ENV["GOPATH"] = buildpath
|
bin_path = buildpath/"#{name}"
|
||||||
|
# Copy all files from their current location to buildpath/#{name}
|
||||||
bin_path = buildpath/"src/{{IMPORT_PATH}}"
|
|
||||||
# Copy all files from their current location (GOPATH root)
|
|
||||||
# to $GOPATH/src/{{IMPORT_PATH}}
|
|
||||||
bin_path.install Dir["*",".??*"]
|
bin_path.install Dir["*",".??*"]
|
||||||
cd bin_path do
|
cd bin_path do
|
||||||
system "dep", "ensure", "--vendor-only"
|
system "make" "vendor"
|
||||||
system "make", "install", "VERSION=#{version}", "ITERATION={{Iter}}", "PREFIX=#{prefix}", "ETC=#{etc}"
|
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
|
# 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
|
# #{var}/log folder. The alternative could be letting the app silently fail
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue