From 8047f59becb37d3f04dfcffa10e018fd7a770f65 Mon Sep 17 00:00:00 2001 From: Philipp Strube Date: Fri, 13 Nov 2015 18:26:39 +0100 Subject: [PATCH] Build PHP for Multiple Stacks fix #50 Build PHP version in Docker containers using our Stack images instead of inside Vagrant VMs that have to be maintained to match the Stack run-time environment seperately. Additionally the `Makefile` and `$STACK/Dockerfile`s allow to build each PHP version for each Stack and can also be extended easily for future Stacks. --- .gitignore | 4 +-- build/Makefile | 20 ++++++++++++++ build/Pinky/Dockerfile | 19 +++++++++++++ build/README.md | 23 ++++++++++++++-- build/Trinity/Dockerfile | 16 +++++++++++ build/Vagrantfile | 16 ----------- build/libmemcached_sasl_memset.patch | 10 ------- build/php-build.sh | 4 ++- build/prepare-vm.sh | 41 ---------------------------- 9 files changed, 80 insertions(+), 73 deletions(-) create mode 100644 build/Makefile create mode 100644 build/Pinky/Dockerfile create mode 100644 build/Trinity/Dockerfile delete mode 100644 build/Vagrantfile delete mode 100644 build/libmemcached_sasl_memset.patch delete mode 100644 build/prepare-vm.sh diff --git a/.gitignore b/.gitignore index d425d60..3ac250d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ -.vagrant/ -build/buildpack-php/* -build/.vagrant/ +build/dist/* diff --git a/build/Makefile b/build/Makefile new file mode 100644 index 0000000..0dcde4a --- /dev/null +++ b/build/Makefile @@ -0,0 +1,20 @@ +all: pinky trinity + +pinky-prepare: + docker build -t pinkyphpbuild:latest Pinky + +pinky-build: + docker run -e "STACK=pinky" -v $(shell pwd):/vagrant -ti pinkyphpbuild:latest /vagrant/php-build.sh $(version) + +pinky: pinky-prepare pinky-build + +trinity-prepare: + docker build -t trinityphpbuild:latest Trinity + +trinity-build: + docker run -e "STACK=trinity" -v $(shell pwd):/vagrant -ti trinityphpbuild:latest /vagrant/php-build.sh $(version) + +trinity: trinity-prepare trinity-build + +clean: + rm -rf dist/* diff --git a/build/Pinky/Dockerfile b/build/Pinky/Dockerfile new file mode 100644 index 0000000..489a28f --- /dev/null +++ b/build/Pinky/Dockerfile @@ -0,0 +1,19 @@ +FROM localhost:5000/cloudcontrol/ccpinky + +MAINTAINER cloudControl + +# Install packages required to build PHP that are not in the runtime stack +RUN apt-get update && apt-get install -y \ + autoconf \ + freetds-dev \ + libbison-dev \ + libicu-dev \ + libmcrypt-dev \ + libreadline-dev \ + re2c + +# Set symlinks for libsybdb so the PHP build can find it +RUN ln -f -s /usr/lib/x86_64-linux-gnu/libsybdb.a /usr/lib/libsybdb.a \ + && ln -f -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/libsybdb.so + +CMD ["/bin/bash"] diff --git a/build/README.md b/build/README.md index 86d6b5c..29b6b43 100644 --- a/build/README.md +++ b/build/README.md @@ -1,7 +1,26 @@ # Build php - vagrant up build - vagrant ssh build -c 'sudo /vagrant/php-build.sh VERSION' +Building PHP requires a working Docker setup with the latest stack images +available. The Makefile does take care of building the docker container and +run the PHP buildscript. + +## Build all Stacks + +``` +make version=VERSION # e.g. php-5.6.12 +``` + +## Build a specific stack + +``` +make STACK version=VERSION # e.g. trinity +``` + +## Cleanup + +``` +make clean +``` ## Builds diff --git a/build/Trinity/Dockerfile b/build/Trinity/Dockerfile new file mode 100644 index 0000000..5d91d36 --- /dev/null +++ b/build/Trinity/Dockerfile @@ -0,0 +1,16 @@ +FROM localhost:5000/cloudcontrol/trinity + +MAINTAINER cloudControl + +# Install packages required to build PHP that are not in the runtime stack +RUN apt-get update && apt-get install -y \ + autoconf \ + freetds-dev \ + libbison-dev \ + re2c + +# Set symlinks for libsybdb so the PHP build can find it +RUN ln -f -s /usr/lib/x86_64-linux-gnu/libsybdb.a /usr/lib/libsybdb.a \ + && ln -f -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/libsybdb.so + +CMD ["/bin/bash"] diff --git a/build/Vagrantfile b/build/Vagrantfile deleted file mode 100644 index acb1886..0000000 --- a/build/Vagrantfile +++ /dev/null @@ -1,16 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -VAGRANTFILE_API_VERSION = "2" - -Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - config.vm.box = "ubuntu/trusty64" - - config.vm.provider "virtualbox" do |v| - v.memory = 1024 - end - - config.vm.define "build" do |web| - config.vm.provision "shell", path: "prepare-vm.sh" - end -end diff --git a/build/libmemcached_sasl_memset.patch b/build/libmemcached_sasl_memset.patch deleted file mode 100644 index 01e555b..0000000 --- a/build/libmemcached_sasl_memset.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/libmemcached/sasl.cc -+++ b/libmemcached/sasl.cc -@@ -171,6 +171,7 @@ - memcached_server_response_increment(server); - - char mech[MEMCACHED_MAX_BUFFER]; -+ memset(mech, 0, sizeof(mech)); - memcached_return_t rc= memcached_response(server, mech, sizeof(mech), NULL); - if (memcached_failed(rc)) - { diff --git a/build/php-build.sh b/build/php-build.sh index 0a84922..6f366cf 100755 --- a/build/php-build.sh +++ b/build/php-build.sh @@ -97,4 +97,6 @@ make -s install cd .. cd ${PHP_DIR}/.. -tar cjf /vagrant/buildpack-php/${PHP_VERSION}.tar.bz2 ${PHP_VERSION} +mkdir -p /vagrant/dist/${STACK} +tar cjf /vagrant/dist/${STACK}/${PHP_VERSION}.tar.bz2 ${PHP_VERSION} +chmod -R 777 /vagrant/dist/${STACK} diff --git a/build/prepare-vm.sh b/build/prepare-vm.sh deleted file mode 100644 index 2f13402..0000000 --- a/build/prepare-vm.sh +++ /dev/null @@ -1,41 +0,0 @@ - -cd /tmp - -export DEBIAN_FRONTEND=noninteractive - -echo "LC_ALL=en_US.UTF-8" > /etc/default/locale -echo "LANG=en_US.UTF-8" >> /etc/default/locale -. /etc/default/locale - -apt-get update -qq -apt-get upgrade -y -qq - -apt-get install -y -qq libxml2-dev libpng-dev libicu-dev libxslt-dev libcurl4-openssl-dev pkg-config libjpeg-dev libfreetype6-dev libmcrypt-dev freetds-dev libbz2-dev libpq-dev libreadline-dev autoconf imagemagick git libtool s3cmd libmagickwand-dev libsasl2-dev libbison-dev re2c python-pip - -# configure: error: Could not find /usr/lib/libsybdb.a|so -ln -f -s /usr/lib/x86_64-linux-gnu/libsybdb.a /usr/lib/libsybdb.a -ln -f -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/libsybdb.so - -curl --silent --location https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz | tar zx -cd libmemcached-1.0.18 -# patch unfixed libmemcached bug causing "No worthy mechs found" log lines -patch -p1 < "/vagrant/libmemcached_sasl_memset.patch" -./configure -q -make -s -make -s install -cd .. - -git clone https://github.com/alanxz/rabbitmq-c.git -cd rabbitmq-c -git checkout v0.5.2 -git submodule update --init -autoreconf -i -./configure -q -make -s -make -s install -cd .. - -ldconfig - -pip install python-dateutil -git clone https://github.com/s3tools/s3cmd.git /home/vagrant/s3cmd