Skip to content

Commit

Permalink
Merge pull request #153 from sttts/docker-build
Browse files Browse the repository at this point in the history
Add docker build container for easy cross-compilation
  • Loading branch information
Jing Dong committed Jul 27, 2015
2 parents fa6ab66 + ff29974 commit ba2a907
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ bamboo
node_modules
.sass-cache
builder/build
builder/*.deb
*.sublime-project
output
21 changes: 21 additions & 0 deletions Dockerfile-deb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM ubuntu:14.04

ENV DEBIAN_FRONTEND noninteractive
ENV GOPATH /opt/go

RUN apt-get update -yqq
RUN apt-get install -yqq golang git mercurial ruby-dev gcc make
RUN gem install fpm

ADD . /opt/go/src/github.com/QubitProducts/bamboo

WORKDIR /opt/go/src/github.com/QubitProducts/bamboo

RUN go get github.com/tools/godep && \
go get -t github.com/smartystreets/goconvey

RUN mkdir -p /output
VOLUME /output

ENV USER root
CMD builder/build.sh && mv builder/bamboo*.deb /output
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,24 @@ curl -i http://localhost:8000/status
## Deployment

We recommend installing binary with deb or rpm package.
The repository includes examples of [a Jenkins build script](https://github.com/QubitProducts/bamboo/blob/master/builder/ci-jenkins.sh)
and [a deb packages build script](https://github.com/QubitProducts/bamboo/blob/master/builder/build.sh).
Read comments in the script to customize your build distribution workflow.

In short, [install fpm](https://github.com/jordansissel/fpm) and run the following command:
The repository includes an example deb package build script called [builder/build.sh](./builder/build.sh) which generates a deb package in `./output`. For this install [fpm](https://github.com/jordansissel/fpm) and run:

```
go build bamboo.go
./builder/build.sh
```

A deb package will be generated in `./builder` directory. You can copy to a server or publish to your own apt repository.
Moreover, there is
- a [Jenkins build script](builder/ci-jenkins.sh) to run `build.sh` from a Jenkins job
- and a [Docker build container](builder/build.sh) which will generate the deb package in the volume mounted output directory:

```
docker build -f Dockerfile-deb -t bamboo-build
docker run -it -v $(pwd)/output bamboo-build
```

Independently how you build the deb package, you can copy it to a server or publish to your own apt repository.

The example deb package deploys:

Expand Down
4 changes: 3 additions & 1 deletion builder/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ workspace="builder"
pkgtype=${_PKGTYPE:-"deb"}
builddir="build"
installdir="opt"
outputdir="output"
function cleanup() {
cd ${origdir}/${workspace}
rm -rf ${name}*.{deb,rpm}
Expand Down Expand Up @@ -68,7 +69,8 @@ function mkdeb() {
--prefix=/ \
-s dir \
-- .
mv ${name}*.${pkgtype} ${origdir}/${workspace}/
mkdir -p ${origdir}/${outputdir}
mv ${name}*.${pkgtype} ${origdir}/${outputdir}/
popd
}

Expand Down
2 changes: 1 addition & 1 deletion builder/ci-jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ if ! gem spec fpm > /dev/null 2>&1; then gem install fpm; fi
./builder/build.sh

# Copy files to workspace root directory
cp $BAMBOO_PROJECT_DIR/builder/*.deb $WORKSPACE/
cp $BAMBOO_PROJECT_DIR/output/*.deb $WORKSPACE/

0 comments on commit ba2a907

Please sign in to comment.