Skip to content

Commit

Permalink
Add new build rigging for multi-OS
Browse files Browse the repository at this point in the history
Given the underlying native library, C lib and other OS lib dependencies
sneak in, so this uses a few different Dockerfiles to build binaries
targetted at specific OSes.
  • Loading branch information
Daniel Hiltgen committed Apr 17, 2017
1 parent 72c6ea9 commit f328c4b
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
cmd/docker-machine-driver-kvm/docker-machine-driver-kvm
*.sw*
docker-machine-driver-kvm-*
15 changes: 15 additions & 0 deletions Dockerfile.alpine3.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine:3.4

MAINTAINER Daniel Hiltgen <[email protected]>

ARG MACHINE_VERSION
ENV GOPATH /go

RUN apk -v add --update libvirt-dev curl go git musl-dev gcc
RUN git clone --branch ${MACHINE_VERSION} https://github.com/docker/machine.git /go/src/github.com/docker/machine

COPY . /go/src/github.com/dhiltgen/docker-machine-kvm
WORKDIR /go/src/github.com/dhiltgen/docker-machine-kvm
RUN go get -v -d ./...

RUN go install -v ./cmd/docker-machine-driver-kvm
15 changes: 15 additions & 0 deletions Dockerfile.alpine3.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine:3.5

MAINTAINER Daniel Hiltgen <[email protected]>

ARG MACHINE_VERSION
ENV GOPATH /go

RUN apk -v add --update libvirt-dev curl go git musl-dev gcc
RUN git clone --branch ${MACHINE_VERSION} https://github.com/docker/machine.git /go/src/github.com/docker/machine

COPY . /go/src/github.com/dhiltgen/docker-machine-kvm
WORKDIR /go/src/github.com/dhiltgen/docker-machine-kvm
RUN go get -v -d ./...

RUN go install -v ./cmd/docker-machine-driver-kvm
18 changes: 18 additions & 0 deletions Dockerfile.centos7
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM centos:7

MAINTAINER Daniel Hiltgen <[email protected]>

ARG MACHINE_VERSION
ARG GO_VERSION
ENV GOPATH /go

RUN yum install -y libvirt-devel curl git gcc
RUN curl -sSL https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz | tar -C /usr/local -xzf -
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin:/go/bin
RUN git clone --branch ${MACHINE_VERSION} https://github.com/docker/machine.git /go/src/github.com/docker/machine

COPY . /go/src/github.com/dhiltgen/docker-machine-kvm
WORKDIR /go/src/github.com/dhiltgen/docker-machine-kvm
RUN go get -v -d ./...

RUN go install -v ./cmd/docker-machine-driver-kvm
18 changes: 18 additions & 0 deletions Dockerfile.ubuntu14.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ubuntu:14.04

MAINTAINER Daniel Hiltgen <[email protected]>

ARG MACHINE_VERSION
ARG GO_VERSION
ENV GOPATH /go

RUN apt-get update && apt-get install -y libvirt-dev curl git gcc
RUN curl -sSL https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz | tar -C /usr/local -xzf -
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin:/go/bin
RUN git clone --branch ${MACHINE_VERSION} https://github.com/docker/machine.git /go/src/github.com/docker/machine

COPY . /go/src/github.com/dhiltgen/docker-machine-kvm
WORKDIR /go/src/github.com/dhiltgen/docker-machine-kvm
RUN go get -v -d ./...

RUN go install -v ./cmd/docker-machine-driver-kvm
18 changes: 18 additions & 0 deletions Dockerfile.ubuntu16.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ubuntu:16.04

MAINTAINER Daniel Hiltgen <[email protected]>

ARG MACHINE_VERSION
ARG GO_VERSION
ENV GOPATH /go

RUN apt-get update && apt-get install -y libvirt-dev curl git gcc
RUN curl -sSL https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz | tar -C /usr/local -xzf -
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin:/go/bin
RUN git clone --branch ${MACHINE_VERSION} https://github.com/docker/machine.git /go/src/github.com/docker/machine

COPY . /go/src/github.com/dhiltgen/docker-machine-kvm
WORKDIR /go/src/github.com/dhiltgen/docker-machine-kvm
RUN go get -v -d ./...

RUN go install -v ./cmd/docker-machine-driver-kvm
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
PREFIX=docker-machine-driver-kvm
MACHINE_VERSION=v0.10.0
GO_VERSION=1.8.1
DESCRIBE=$(shell git describe --tags)

TARGETS=$(addprefix $(PREFIX)-, alpine3.4 alpine3.5 ubuntu14.04 ubuntu16.04 centos7)

build: $(TARGETS)

$(PREFIX)-%: Dockerfile.%
docker rmi -f $@ >/dev/null 2>&1 || true
docker rm -f $@-extract > /dev/null 2>&1 || true
echo "Building binaries for $@"
docker build --build-arg "MACHINE_VERSION=$(MACHINE_VERSION)" --build-arg "GO_VERSION=$(GO_VERSION)" -t $@ -f $< .
docker create --name $@-extract $@ sh
docker cp $@-extract:/go/bin/docker-machine-driver-kvm ./
mv ./docker-machine-driver-kvm ./$@
docker rm $@-extract || true
docker rmi $@ || true

clean:
rm -f ./$(PREFIX)-*


release: build
@echo "Paste the following into the release page on github and upload the binaries..."
@echo ""
@for bin in $(PREFIX)-* ; do \
target=$$(echo $${bin} | cut -f5- -d-) ; \
md5=$$(md5sum $${bin}) ; \
echo "* $${target} - md5: $${md5}" ; \
echo '```' ; \
echo " curl -L https://github.com/dhiltgen/docker-machine-kvm/releases/download/$(DESCRIBE)/$${bin} > /usr/local/bin/$(PREFIX) \\ " ; \
echo " chmod +x /usr/local/bin/$(PREFIX)" ; \
echo '```' ; \
done

0 comments on commit f328c4b

Please sign in to comment.