Skip to content

Commit

Permalink
Fix image release
Browse files Browse the repository at this point in the history
  • Loading branch information
dtaniwaki committed Jun 14, 2019
1 parent 1c6f01e commit e2ba28b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
19 changes: 9 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
####################################################################################################
# git-ghost-dev
####################################################################################################
FROM golang:1.11.4 as git-ghost-dev
FROM golang:1.12.6 as git-ghost-dev


RUN apt-get update -q && apt-get install -yq --no-install-recommends \
Expand Down Expand Up @@ -43,24 +43,23 @@ ENV GITHUB_RELEASE_VERSION=0.7.2
RUN curl -sLo- https://github.com/aktau/github-release/releases/download/v${GITHUB_RELEASE_VERSION}/linux-amd64-github-release.tar.bz2 | \
tar -xjC "$GOPATH/bin" --strip-components 3 -f-

# A dummy directory is created under $GOPATH/src/dummy so we are able to use dep
# to install all the packages of our dep lock file
COPY Gopkg.toml ${GOPATH}/src/dummy/Gopkg.toml
COPY Gopkg.lock ${GOPATH}/src/dummy/Gopkg.lock
WORKDIR $GOPATH/src/git-ghost
ENV GO111MODULE=on

RUN cd ${GOPATH}/src/dummy && \
dep ensure -vendor-only && \
mv vendor/* ${GOPATH}/src/ && \
rmdir vendor
# First, warm up the go modules cache.
COPY go.mod go.sum ${GOPATH}/src/git-ghost/
RUN cd ${GOPATH}/src/git-ghost && go mod download

WORKDIR $GOPATH/src/git-ghost
# Now, we actually copy all the files.
COPY . .

####################################################################################################
# builder
####################################################################################################
FROM git-ghost-dev as builder

ARG VERSION

# Perform the build
RUN make build

Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NAME := git-ghost
PROJECTROOT := $(shell pwd)
VERSION ?= $(shell cat ${PROJECTROOT}/VERSION)-dev
VERSION := $(if $(VERSION),$(VERSION),$(shell cat ${PROJECTROOT}/VERSION)-dev)
REVISION := $(shell git rev-parse --short HEAD)
IMAGE_PREFIX ?= dtaniwaki/
IMAGE_TAG ?= $(VERSION)
Expand Down Expand Up @@ -83,11 +83,10 @@ release-assets: guard-RELEASE_TAG guard-RELEASE_COMMIT guard-GITHUB_USER guard-G
git checkout -

.PHONY: release-image
release-image: IMAGE_TAG=$(RELEASE_TAG)
release-image: guard-RELEASE_TAG
git diff --quiet HEAD || (echo "your current branch is dirty" && exit 1)
git checkout $(RELEASE_COMMIT)
make build-image-cli
make build-image-cli VERSION=$(shell cat ${PROJECTROOT}/VERSION)
docker push $(IMAGE_PREFIX)git-ghost-cli:$(RELEASE_TAG)
git checkout -

Expand All @@ -101,7 +100,7 @@ build-image-dev:

.PHONY: build-image-cli
build-image-cli:
docker build -t $(IMAGE_PREFIX)git-ghost-cli:$(IMAGE_TAG) --target git-ghost-cli $(PROJECTROOT)
docker build -t $(IMAGE_PREFIX)git-ghost-cli:$(IMAGE_TAG) --build-arg VERSION=$(VERSION) --target git-ghost-cli $(PROJECTROOT)

.PHONY: build-image-all
build-image-all: build-image-dev build-image-cli
Expand Down

0 comments on commit e2ba28b

Please sign in to comment.