From e621ff4d5ed37bc3fd68fe9c873ae23811824825 Mon Sep 17 00:00:00 2001 From: Ed Morley <edmorley@users.noreply.github.com> Date: Thu, 25 May 2017 19:55:57 +0100 Subject: [PATCH] Improve the workflow for generating binaries for Heroku-16 (#387) * Updates bob-builder to a version that clears out the previous build directory, which prevents the stale files seen in #379. * Adds a `buildenv-heroku-16` Make command to simplify the building and use of the Heroku-16 binary build environment. * Sets `S3_BUCKET` and `S3_PREFIX` in the Docker image, to save having to do so manually each time. * Removes the duplication of the bob-builder dependency between `Dockerfile` and `requirements.txt`. * Disables the pip version check during Docker build, to avoid the noisy stderr warning about Ubuntu 16.04 pip being older (v8.1.1). * Adds a `.dockerignore` to speed up the Docker build, by reducing the build context transferred to the daemon from 60MB to 2MB. * Applies some Dockerfile best practices like disabling/removing cached files (since layer invalidation makes caching pointless). --- .dockerignore | 1 + Dockerfile | 12 +++++++----- Makefile | 15 ++++++++++++++- builds/README.md | 12 +++++++++++- requirements.txt | 3 ++- 5 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..2d2ecd68 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.git/ diff --git a/Dockerfile b/Dockerfile index 6fdfebf7..7a785619 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,13 @@ FROM heroku/heroku:16-build WORKDIR /app -ENV WORKSPACE_DIR=/app/builds +ENV WORKSPACE_DIR="/app/builds" \ + S3_BUCKET="lang-python" \ + S3_PREFIX="heroku-16/" -RUN apt-get update && apt-get install -y python-pip +RUN apt-get update && apt-get install -y python-pip && rm -rf /var/lib/apt/lists/* -# Install bob-builder application -RUN pip install bob-builder==0.0.5 +COPY requirements.txt /app/ +RUN pip install --disable-pip-version-check --no-cache-dir -r /app/requirements.txt -COPY . /app \ No newline at end of file +COPY . /app diff --git a/Makefile b/Makefile index 617be31e..19045674 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,20 @@ test-heroku-16: @docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=heroku-16" heroku/heroku:16-build bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run;' @echo "" +buildenv-heroku-16: + @echo "Creating build environment (heroku-16)..." + @echo + @docker build --pull -t python-buildenv-heroku-16 . + @echo + @echo "Usage..." + @echo + @echo " $$ export AWS_ACCESS_KEY_ID=foo AWS_SECRET_ACCESS_KEY=bar # Optional unless deploying" + @echo " $$ bob build runtimes/python-2.7.13" + @echo " $$ bob deploy runtimes/python-2.7.13" + @echo + @docker run -it --rm python-buildenv-heroku-16 + tools: git clone https://github.com/kennethreitz/pip-pop.git mv pip-pop/bin/* vendor/pip-pop/ - rm -fr pip-pop \ No newline at end of file + rm -fr pip-pop diff --git a/builds/README.md b/builds/README.md index a33c3adb..29497439 100644 --- a/builds/README.md +++ b/builds/README.md @@ -1,5 +1,7 @@ # Python Buildpack Binaries +For Cedar-14 stack +------------------ To get started with it, create an app on Heroku inside a clone of this repository, and set your S3 config vars: @@ -28,4 +30,12 @@ If this works, run `bob deploy` instead of `bob build` to have the result upload To speed things up drastically, it'll usually be a good idea to `heroku run bash --size PX` instead. -Enjoy :) \ No newline at end of file +For Heroku-16 stack +------------------- + +1. Ensure GNU Make and Docker are installed. +2. From the root of the buildpack repository, run: `make buildenv-heroku-16` +3. Follow the instructions displayed! + + +Enjoy :) diff --git a/requirements.txt b/requirements.txt index 394d44ad..eadd035c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -bob-builder==0.0.5 +# TODO: Replace this once the bob-builder changes on master are released: +https://github.com/kennethreitz/bob-builder/archive/54211376a8fb49c67ecbd6798bd45b55f4d125f4.zip -- GitLab