Skip to content

Commit

Permalink
Add a build process for Dockramp binaries
Browse files Browse the repository at this point in the history
Docker-DCO-1.1-Signed-off-by: Josh Hawn <[email protected]> (github: jlhawn)
  • Loading branch information
Josh Hawn committed Jul 27, 2015
1 parent 7749a98 commit d78a759
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Folders
_obj
_test
bundles

# Architecture specific extensions/prefixes
*.[568vq]
Expand Down
17 changes: 12 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
FROM golang:1.4.2
FROM golang:1.4.2-cross

MAINTAINER 'Josh Hawn <[email protected]> (github:jlhawn)'

ENV PROJ_DIR /go/src/github.com/jlhawn/dockramp

ENV PLATFORMS '
darwin/386 darwin/amd64
freebsd/386 freebsd/amd64 freebsd/arm
linux/386 linux/amd64 linux/arm
windows/386 windows/amd64
'

RUN sh -c 'mkdir -p $PROJ_DIR'

COPY . $PROJ_DIR

RUN sh << EOF
export GOPATH="$PROJ_DIR/Godeps/_workspace:$GOPATH"
go build -o /usr/local/bin/dockramp github.com/jlhawn/dockramp/cmd/dockramp
EOF
RUN sh -c 'cp "$PROJ_DIR/make_binaries.sh" /usr/local/bin/make_binaries.sh'

ENTRYPOINT /usr/local/bin/make_binaries.sh
CMD /bundles
2 changes: 1 addition & 1 deletion Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Set an output prefix, which is the local directory if not specified
GIT_BRANCH=$(shell git rev-parse --abbrev-ref HEAD)

.PHONY: all clean image binaries

all: clean binaries

clean:
@echo "+ $@"
@rm -rf bundles

image:
@echo "+ $@"
@dockramp -t dockramp:${GIT_BRANCH}

binaries: image
@echo "+ $@"
$(eval C_ID := $(shell docker create dockramp:${GIT_BRANCH}))
@docker start -a ${C_ID}
@docker cp ${C_ID}:/bundles .
@docker rm ${C_ID}
24 changes: 24 additions & 0 deletions make_binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

FAILURES=""
TARGET="github.com/jlhawn/dockramp/cmd/dockramp"

mkdir "$1"

for PLATFORM in $PLATFORMS; do
OUTPUTDIR="$1/$PLATFORM"
mkdir -p "$OUTPUTDIR"

export GOPATH="$PROJ_DIR/Godeps/_workspace:$GOPATH"
export GOOS="${PLATFORM%/*}"
export GOARCH="${PLATFORM#*/}"

CMD="go build -o $OUTPUTDIR/dockramp $TARGET"

echo "$CMD" && $CMD || FAILURES="$FAILURES $PLATFORM"
done

if [ -n "$FAILURES" ]; then
echo "*** build FAILED on $FAILURES ***"
exit 1
fi

0 comments on commit d78a759

Please sign in to comment.