From 81173edda45905632667d0dacb2bf59eac1bfee3 Mon Sep 17 00:00:00 2001 From: Chris Gaffney Date: Mon, 4 Dec 2017 15:56:18 -0500 Subject: [PATCH] Rewrite build system for new versions and Heroku stacks This allows new versions to be built for uploading by running `make VERSION=5.0.1` rather than updating the hard coded version in multiple places. I've also added support for building against either the legacy cedar-14 architecture or heroku-16. While versions built on cedar-14 appear to run on heroku-16, the newer stack should also mean a newer and better tool chain. I've removed the Dockerfile and switched to using Heroku's docker images directly as this removes the need for cleaning them up afterwards. It possibly makes debugging harder but having build.sh available should avoid some of that. Fixes #2 Fixes #7 Fixes #13 --- Dockerfile | 11 ----------- Makefile | 38 +++++++++++++++++++++++++------------- README.md | 4 ++-- build.sh | 17 +++++++++++++++++ 4 files changed, 44 insertions(+), 26 deletions(-) delete mode 100644 Dockerfile create mode 100755 build.sh diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 4c2eaf6..0000000 --- a/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM heroku/cedar - -ENV DEBIAN_FRONTEND noninteractive - -ADD src/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 . diff --git a/Makefile b/Makefile index 79215a6..e3d2604 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,33 @@ -default: dist/jemalloc-5.0.0-1.tar.gz +default: heroku-16 cedar-14 -dist/jemalloc-5.0.0-1.tar.gz: jemalloc-cedar - docker cp $<:/tmp/jemalloc-cedar.tar.gz . - mkdir -p $$(dirname $@) - mv jemalloc-cedar.tar.gz $@ +VERSION := 5.0.1 +ROOT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) clean: rm -rf src/ dist/ - -docker rm jemalloc-cedar -src/jemalloc.tar.bz2: +# Download missing source archives to ./src/ +src/jemalloc-%.tar.bz2: mkdir -p $$(dirname $@) - curl -sL https://github.com/jemalloc/jemalloc/releases/download/5.0.0/jemalloc-5.0.0.tar.bz2 -o $@ + curl -fsL https://github.com/jemalloc/jemalloc/releases/download/$*/jemalloc-$*.tar.bz2 -o $@ + +.PHONY: cedar-14 heroku-16 + +# Build for cedar stack (deprecated) +cedar-14: src/jemalloc-$(VERSION).tar.bz2 + docker run -it --volume="$(ROOT_DIR):/wrk" \ + heroku/cedar:14 /wrk/build.sh $(VERSION) cedar-14 -.PHONY: jemalloc-cedar +# Build for heroku-16 stack +heroku-16: src/jemalloc-$(VERSION).tar.bz2 + docker run -it --volume="$(ROOT_DIR):/wrk" \ + heroku/heroku:16-build /wrk/build.sh $(VERSION) heroku-16 -jemalloc-cedar: src/jemalloc.tar.bz2 - docker build --rm -t mojodna/$@ . - -docker rm $@ - docker run --name $@ mojodna/$@ /bin/echo $@ +# Build recent releases for heroku-16 and cedar +all: + $(MAKE) cedar-14 VERSION=3.6.0 + $(MAKE) cedar-14 VERSION=4.5.0 + $(MAKE) cedar-14 VERSION=5.0.1 + $(MAKE) heroku-16 VERSION=3.6.0 + $(MAKE) heroku-16 VERSION=4.5.0 + $(MAKE) heroku-16 VERSION=5.0.1 diff --git a/README.md b/README.md index 134291f..f34ff3a 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ This uses Docker to build against Heroku [stack-image](https://github.com/heroku/stack-images)-like images. ```bash -make +make VERSION=5.0.1 ``` -Artifacts will be dropped in `dist/`. See `Dockerfile`s for build options. +Artifacts will be dropped in `dist/` based on Heroku stack and jemalloc version. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..50050f3 --- /dev/null +++ b/build.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# usage: build [version] [stack] +set -e + +version=$1 +stack=$2 +build=`mktemp -d` + +tar -C $build --strip-components=1 -xj -f /wrk/src/jemalloc-$version.tar.bz2 + +cd $build +./configure --prefix=/app/vendor/jemalloc +make install_bin install_include install_lib_shared install_lib_static + +# Bundle and compress the compiled library +mkdir -p /wrk/dist/$stack +tar -C /app/vendor/jemalloc -zc -f /wrk/dist/$stack/jemalloc-$version.tar.gz .