Skip to content

Commit 7336588

Browse files
author
Kevin Smith
committed
Enable preview builds on Docker Hub
2 parents 6324f42 + 92ed170 commit 7336588

File tree

4 files changed

+31
-21
lines changed

4 files changed

+31
-21
lines changed

.dockerignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
*
2-
!_build/relay
3-
!docker/relay.conf

Dockerfile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
FROM gliderlabs/alpine:latest
1+
FROM alpine:3.4
22

33
MAINTAINER Kevin Smith <kevin@operable.io>
44

5-
COPY _build/relay /usr/local/bin/relay
6-
COPY docker/relay.conf /usr/local/etc/relay.conf
5+
ARG GIT_COMMIT
6+
ENV GIT_COMMIT ${GIT_COMMIT:-master}
77

8-
# RUN chmod +x /usr/local/bin/relay
8+
RUN mkdir -p /root/golang/src/github.com/operable/ && \
9+
cd /root/golang/src/github.com/operable && \
10+
apk add -U --no-cache git go make ca-certificates && \
11+
git clone https://github.com/operable/go-relay && \
12+
cd go-relay && git checkout $GIT_COMMIT && \
13+
GOPATH=/root/golang make exe && \
14+
cp _build/relay /usr/local/bin && \
15+
mkdir -p /usr/local/etc && \
16+
cp docker/relay.conf /usr/local/etc/relay.conf && \
17+
cd /root && rm -rf golang && \
18+
apk del --force --rdepends --purge go make git && rm -rf /var/cache/apk/*
919

10-
# Ensure latest CA certs are available
11-
RUN apk-install ca-certificates && chmod +x /usr/local/bin/relay

Makefile

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,14 @@ SOURCES := $(shell find . -name "*.go" -type f)
66
VET_FLAGS = -v
77
BUILD_STAMP := $(shell date -u '+%Y%m%d%H%M%S')
88
BUILD_HASH := $(shell git rev-parse HEAD)
9-
BUILD_TAG ?= $(shell git describe --tags)
9+
BUILD_TAG ?= $(shell scripts/build_tag.sh)
1010
DRIVER_TAG ?= 0.9.1
11-
DOCKER_IMAGE ?= "operable/relay:dev"
11+
DOCKER_IMAGE ?= "operable/relay:$(BUILD_TAG)"
1212
LINK_VARS := -X main.buildstamp=$(BUILD_STAMP) -X main.buildhash=$(BUILD_HASH)
1313
LINK_VARS += -X main.buildtag=$(BUILD_TAG) -X main.commanddrivertag=$(DRIVER_TAG)
14-
OSNAME := $(shell uname | tr A-Z a-z)
15-
ARCHNAME := $(shell $(CC) -dumpmachine | cut -d\- -f1)
1614
BUILD_DIR = _build
1715
EXENAME = relay
1816

19-
ifeq ($(ARCHNAME), x86_64)
20-
ARCHNAME = amd64
21-
endif
22-
TARBALL_NAME = $(EXENAME)_$(OSNAME)_$(ARCHNAME)
23-
24-
2517
ifdef FORCE
2618
.PHONY: all tools lint test clean deps relay docker
2719
else
@@ -70,9 +62,8 @@ $(TARBALL_NAME): test exe
7062
tar czf $(TARBALL_NAME).tar.gz $(TARBALL_NAME)
7163
rm -rf $(TARBALL_NAME)
7264

73-
docker: clean
74-
GOOS=linux GOARCH=amd64 make deps exe
75-
docker build -t $(DOCKER_IMAGE) .
65+
docker:
66+
docker build --build-arg=GIT_COMMIT=$(BUILD_HASH) -t $(DOCKER_IMAGE) .
7667

7768
$(BUILD_DIR):
7869
mkdir -p $@

scripts/build_tag.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# git describe --tags appends SHA info to
4+
# prior tag. This subcommand detects when that
5+
# happens.
6+
tag=`git describe --tags`
7+
dash_count=`git describe --tags | grep -o - | wc -l | sed "s/ //g"`
8+
9+
if [ "$dash_count" != "0" ]; then
10+
tag="dev"
11+
fi
12+
13+
echo $tag

0 commit comments

Comments
 (0)