Skip to content

Commit

Permalink
Make builds repeatable using Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
mojodna committed Oct 12, 2014
1 parent ac2bf57 commit 1e2ce63
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 24 deletions.
6 changes: 6 additions & 0 deletions .gitignore
@@ -0,0 +1,6 @@
src/
dist/
cedar-stack/
cedar-14-stack/
jemalloc-cedar/
jemalloc-cedar-14/
62 changes: 62 additions & 0 deletions Makefile
@@ -0,0 +1,62 @@
default: cedar cedar-14

cedar: dist/cedar/jemalloc-3.6.0-1.tar.gz

cedar-14: dist/cedar-14/jemalloc-3.6.0-1.tar.gz

dist/cedar/jemalloc-3.6.0-1.tar.gz: jemalloc-cedar
docker cp $<:/tmp/jemalloc-cedar.tar.gz .
mkdir -p $$(dirname $@)
mv jemalloc-cedar.tar.gz $@

dist/cedar-14/jemalloc-3.6.0-1.tar.gz: jemalloc-cedar-14
docker cp $<:/tmp/jemalloc-cedar-14.tar.gz .
mkdir -p $$(dirname $@)
mv jemalloc-cedar-14.tar.gz $@

clean:
rm -rf src/ cedar*/*.sh dist/ jemalloc-cedar*/*.tar.*
-docker rm jemalloc-cedar
-docker rm jemalloc-cedar-14

src/jemalloc.tar.bz2:
mkdir -p $$(dirname $@)
curl -sL http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2 -o $@

.PHONY: cedar-stack

cedar-stack: cedar-stack/cedar.sh
@(docker images -q mojodna/$@ | wc -l | grep 1 > /dev/null) || \
docker build --rm -t mojodna/$@ $@

cedar-stack/cedar.sh:
curl -sLR https://raw.githubusercontent.com/heroku/stack-images/master/bin/cedar.sh -o $@

.PHONY: cedar-14-stack

cedar-14-stack: cedar-14-stack/cedar-14.sh
@(docker images -q mojodna/$@ | wc -l | grep 1 > /dev/null) || \
docker build --rm -t mojodna/$@ $@

cedar-14-stack/cedar-14.sh:
curl -sLR https://raw.githubusercontent.com/heroku/stack-images/master/bin/cedar-14.sh -o $@

.PHONY: jemalloc-cedar

jemalloc-cedar: cedar-stack jemalloc-cedar/jemalloc.tar.bz2
docker build --rm -t mojodna/$@ $@
-docker rm $@
docker run --name $@ mojodna/$@ /bin/echo $@

jemalloc-cedar/jemalloc.tar.bz2: src/jemalloc.tar.bz2
ln -f $< $@

.PHONY: jemalloc-cedar-14

jemalloc-cedar-14: cedar-14-stack jemalloc-cedar-14/jemalloc.tar.bz2
docker build --rm -t mojodna/$@ $@
-docker rm $@
docker run --name $@ mojodna/$@ /bin/echo $@

jemalloc-cedar-14/jemalloc.tar.bz2: src/jemalloc.tar.bz2
ln -f $< $@
28 changes: 4 additions & 24 deletions README.md
Expand Up @@ -49,31 +49,11 @@ git push heroku master

## Building

jemalloc was built in a [cedar stack
image](https://github.com/heroku/stack-images) using the following steps.

`chroot` preparation:
This uses Docker to build against Heroku
[stack-image](https://github.com/heroku/stack-images)-like images.

```bash
mkdir app tmp
sudo /vagrant/bin/install-stack cedar64-2.0.0.img.gz
sudo mount -o bind /dev /mnt/stacks/cedar64-2.0.0/dev/
sudo mount -o bind /home/vagrant/tmp /mnt/stacks/cedar64-2.0.0/tmp/
sudo mount -o bind /home/vagrant/app /mnt/stacks/cedar64-2.0.0/app/
make
```

jemalloc build/package:

```bash
cd tmp/
curl -LO http://www.canonware.com/download/jemalloc/jemalloc-3.4.0.tar.bz2
sudo chroot /mnt/stacks/cedar64-2.0.0
cd /tmp
tar jxf jemalloc-3.4.0.tar.bz2
cd jemalloc-3.4.0
./configure --prefix=/app/vendor/jemalloc
make -j4
make install_bin install_include install_lib_shared install_lib_static
cd /app/vendor/jemalloc
tar zcf /tmp/jemalloc-3.4.0-1.tar.gz .
```
Artifacts will be dropped in `dist/`. See `Dockerfile`s for build options.
28 changes: 28 additions & 0 deletions cedar-14-stack/Dockerfile
@@ -0,0 +1,28 @@
FROM ubuntu:14.04

ENV DEBIAN_FRONTEND noninteractive

# Initialize cedar-14 stack
ADD ./cedar-14.sh /tmp/cedar-14.sh
RUN \
/bin/bash /tmp/cedar-14.sh

RUN \
apt-get upgrade -y

ADD ./postgresql.tar.gz /tmp
RUN \
mkdir -p /app/vendor && \
cd /tmp/postgresql-* && \
./configure --prefix=/app/vendor/pgsql --with-openssl

RUN \
cd /tmp/postgresql-* && \
make -C src/bin install-strip && \
cp src/backend/utils/fmgroids.h src/include/utils/fmgroids.h && \
make -C src/include install-strip && \
make -C src/interfaces install-strip

RUN \
cd /app/vendor/pgsql && \
tar zcf /tmp/pgsql-cedar-14-stack.tar.gz .
11 changes: 11 additions & 0 deletions cedar-stack/Dockerfile
@@ -0,0 +1,11 @@
FROM ubuntu:10.04

ENV DEBIAN_FRONTEND noninteractive

# Initialize cedar stack
ADD ./cedar.sh /tmp/cedar.sh
RUN \
/bin/bash /tmp/cedar.sh

RUN \
apt-get upgrade -y
15 changes: 15 additions & 0 deletions jemalloc-cedar-14/Dockerfile
@@ -0,0 +1,15 @@
FROM mojodna/cedar-14-stack

ENV DEBIAN_FRONTEND noninteractive

RUN \
apt-get upgrade -y

ADD ./jemalloc.tar.bz2 /tmp
RUN \
cd /tmp/jemalloc-* && \
./configure --prefix=/app/vendor/jemalloc && \
make install_bin install_include install_lib_shared install_lib_static && \
cd /app/vendor/jemalloc && \
tar zcf /tmp/jemalloc-cedar-14.tar.gz .

14 changes: 14 additions & 0 deletions jemalloc-cedar/Dockerfile
@@ -0,0 +1,14 @@
FROM mojodna/cedar-stack

ENV DEBIAN_FRONTEND noninteractive

RUN \
apt-get upgrade -y

ADD ./jemalloc.tar.bz2 /tmp
RUN \
cd /tmp/jemalloc-* && \
./configure --prefix=/app/vendor/jemalloc && \
make install_bin install_include install_lib_shared install_lib_static && \
cd /app/vendor/jemalloc && \
tar zcf /tmp/jemalloc-cedar.tar.gz .

0 comments on commit 1e2ce63

Please sign in to comment.