Commit 775e4c7c authored by Evili del Rio's avatar Evili del Rio
parents 2a6dbe4e 0c66cea0
name: Check Changelog
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Check that CHANGELOG is touched
run: |
cat $GITHUB_EVENT_PATH | jq .pull_request.title | grep -i '\[\(\(changelog skip\)\|\(ci skip\)\)\]' || git diff remotes/origin/${{ github.base_ref }} --name-only | grep CHANGELOG.md
......@@ -7,3 +7,6 @@ repos/*
#Venv
buildpack/*
builds/dockerenv.staging*
builds/dockerenv.production
repos:
- repo: git://github.com/detailyang/pre-commit-shell
rev: 1.0.4
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: shell-lint
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
language: ruby
dist: trusty
sudo: required
rvm:
- 2.4.4
before_script:
- gem install bundler -v 1.16.2
- bundle exec hatchet ci:setup
script:
- docker build --pull --tag travis-build-cedar-14 --file $(pwd)/builds/cedar-14.Dockerfile .
- docker run --rm -e "STACK=cedar-14" travis-build-cedar-14 bash $TESTFOLDER
- docker build --pull --tag travis-build-heroku-16 --file $(pwd)/builds/heroku-16.Dockerfile .
- docker run --rm -e "STACK=heroku-16" travis-build-heroku-16 bash $TESTFOLDER
- docker build --pull --tag travis-build-heroku-18 --file $(pwd)/builds/heroku-18.Dockerfile .
- docker run --rm -e "STACK=heroku-18" travis-build-heroku-18 bash $TESTFOLDER
jobs:
include:
- stage: Bash linting (shellcheck)
sudo: false
before_install:
- wget -c https://goo.gl/ZzKHFv -O - | tar -xvJ -C /tmp/
- PATH="/tmp/shellcheck-latest:$PATH"
script: make check
- stage: Stack Unit Tests
services: docker
env: STACK=heroku-18
script: "./tests.sh"
- stage: Stack Unit Tests
services: docker
env: STACK=heroku-16
script: "./tests.sh"
- stage: Stack Unit Tests
services: docker
env: STACK=cedar-14
script: "./tests.sh"
- stage: Hatchet Integration
if: branch = master
name: Run Hatchet
script: "bundle exec rspec"
env:
matrix:
- TESTFOLDER=test/run-deps
- TESTFOLDER=test/run-versions
- TESTFOLDER=test/run-features
global:
- HATCHET_RETRIES=3
- IS_RUNNING_ON_CI=true
- HATCHET_APP_LIMIT=5
- HATCHET_DEPLOY_STRATEGY=git
- secure: yjtlPE5FbVxTKnjUy/tZUBgSEf4qADD3QOxtgziuid73S0U/1IEXlMGFULsQzIjtlHKmHeywZqpVVEpthIH4RuT7uoX1Pb7SSM/g0T8fT3VoEFbFK1uYl0oZQbUS4Klxv9tPiumj8if3m6ULEGIz1X0wZcMOC0tMLwVCnwmap0E=
- secure: ZeFTHWwnpIKE9nAqs88ocmiQh7bKce84lilGm5J23nf3N6V4wNyLwqlkvsM008WGBCaOg9AUx7ZunasT0ANsR5gLP3eV2UUg7ILdRgV2Gy13eNRFheC4PHdN92RqQ3aKoqlIv2K999xlhVjod0NzhkQQXB6PddfQINbuU7ks6As=
- HATCHET_RETRIES=3
- IS_RUNNING_ON_CI=true
- HATCHET_APP_LIMIT=5
- HATCHET_DEPLOY_STRATEGY=git
- secure: yjtlPE5FbVxTKnjUy/tZUBgSEf4qADD3QOxtgziuid73S0U/1IEXlMGFULsQzIjtlHKmHeywZqpVVEpthIH4RuT7uoX1Pb7SSM/g0T8fT3VoEFbFK1uYl0oZQbUS4Klxv9tPiumj8if3m6ULEGIz1X0wZcMOC0tMLwVCnwmap0E=
- secure: ZeFTHWwnpIKE9nAqs88ocmiQh7bKce84lilGm5J23nf3N6V4wNyLwqlkvsM008WGBCaOg9AUx7ZunasT0ANsR5gLP3eV2UUg7ILdRgV2Gy13eNRFheC4PHdN92RqQ3aKoqlIv2K999xlhVjod0NzhkQQXB6PddfQINbuU7ks6As=
# Python Buildpack Changelog
# 146 (2018-15-08)
# Master
--------------------------------------------------------------------------------
# 160 (2019-10-23)
- Bugfix: Pipenv no longer installs twice in CI
# 159 (2019-10-22)
- Python 2.7.17 now available on Heroku 18 and 16.
# 158 (2019-10-21)
- Python 3.7.5 and 3.8.0 now available on Heroku 18 and 16.
- Add support for Python 3.8 branch
- Sqlite3 Update:
- Test Improvements
- Add support for staging binary testing
# 157 (2019-09-18)
- Typo fixes
# 156 (2019-09-12)
- Python 3.6.9 and 3.7.4 now available.
- Move get-pip utility to S3
- Build utility and documentation updates
- Bump Hatchet tests to point at new default python version.
# 155 (2019-08-22)
add docs and make target for heroku-18 bob builds
# 154 (2019-07-17)
Fix python 3.5.7 formula actually building 3.7.2
# 153 (2019-06-21)
Hotfix for broken heroku-16 deploys
# 152 (2019-04-04)
Python 3.7.3 now available.
# 151 (2019-03-21)
Python 3.5.7 and 3.4.10 now available on all Heroku stacks.
# 150 (2019-03-13)
Python 2.7.16 now available on all Heroku stacks.
# 149 (2019-03-04)
Hotfix for broken Cedar 14 deploys
# 148 (2019-02-21)
No user facing changes, improving internal metrics
# 147 (2019-02-07)
Python 3.7.2 and 3.6.8 now available on all Heroku stacks.
# 146 (2018-11-11)
Python 3.7.1, 3.6.7, 3.5.6 and 3.4.9 now available on all Heroku stacks.
......
# These targets are not files
.PHONY: tests
test: test-heroku-18 test-heroku-16
test: test-heroku-18 test-heroku-16 test-cedar-14
check:
@shellcheck -x bin/compile bin/detect bin/release bin/test-compile bin/utils bin/warnings
@shellcheck -x bin/compile bin/detect bin/release bin/test-compile bin/utils bin/warnings bin/default_pythons
@shellcheck -x bin/steps/collectstatic bin/steps/eggpath-fix bin/steps/eggpath-fix2 bin/steps/gdal bin/steps/geo-libs bin/steps/mercurial bin/steps/nltk bin/steps/pip-install bin/steps/pip-uninstall bin/steps/pipenv bin/steps/pipenv-python-version bin/steps/pylibmc bin/steps/python
@shellcheck -x bin/steps/hooks/*
test-cedar-14:
@echo "Running tests in docker (cedar-14)..."
@docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=cedar-14" heroku/cedar:14 bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run;'
@docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=cedar-14" heroku/cedar:14 bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run-deps; test/run-features; test/run-versions;'
@echo ""
test-heroku-16:
@echo "Running tests in docker (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;'
@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-deps; test/run-features; test/run-versions;'
@echo ""
test-heroku-18:
@echo "Running tests in docker (heroku-18)..."
@docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=heroku-18" heroku/heroku:18-build bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run;'
@docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=heroku-18" heroku/heroku:18-build bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run-deps; test/run-features; test/run-versions;'
@echo ""
buildenv-heroku-16:
@echo "Creating build environment (heroku-16)..."
@echo
@docker build --pull -t python-buildenv-heroku-16 .
@docker build --pull -f $(shell pwd)/builds/heroku-16.Dockerfile -t python-buildenv-heroku-16 .
@echo
@echo "Usage..."
@echo
......@@ -36,6 +36,19 @@ buildenv-heroku-16:
@echo
@docker run -it --rm python-buildenv-heroku-16
buildenv-heroku-18:
@echo "Creating build environment (heroku-18)..."
@echo
@docker build --pull -f $(shell pwd)/builds/heroku-18.Dockerfile -t python-buildenv-heroku-18 .
@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-18
tools:
git clone https://github.com/kennethreitz/pip-pop.git
mv pip-pop/bin/* vendor/pip-pop/
......
......@@ -26,7 +26,7 @@ remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.7.1
remote: -----> Installing python-3.7.4
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
......@@ -44,7 +44,7 @@ A `requirements.txt` must be present at the root of your application's repositor
To specify your python version, you also need a `runtime.txt` file - unless you are using the default Python runtime version.
Current default Python Runtime: Python 3.6.7
Current default Python Runtime: Python 3.6.9
Alternatively, you can provide a `setup.py` file, or a `Pipfile`. Using `Pipenv` will generate `runtime.txt` based on `python-version` at build time.
......@@ -61,9 +61,9 @@ Specify a Python Runtime
Supported runtime options include:
- `python-3.7.1`
- `python-3.6.7`
- `python-2.7.15`
- `python-3.7.4`
- `python-3.6.9`
- `python-2.7.17`
## Tests
......
......@@ -42,21 +42,17 @@ export BUILD_DIR CACHE_DIR ENV_DIR
VENDOR_URL="https://lang-python.s3.amazonaws.com/$STACK"
if [[ -n ${BUILDPACK_VENDOR_URL:-} ]]; then
VENDOR_URL="$BUILDPACK_VENDOR_URL"
elif [[ -n ${USE_STAGING_BINARIES} ]]; then
VENDOR_URL="$USE_STAGING_BINARIES/$STACK"
fi
export VENDOR_URL
# Which versions of Python are we using?
# These variables are used to specify which versions of Python to install by default,
# as well as prompt the user to upgrade if they are using an un–supported version.
# Note: When 3.7 lands, I recommend switching to LATEST_36 and LATEST_37.
DEFAULT_PYTHON_VERSION="python-3.6.7"
LATEST_36="python-3.6.7"
LATEST_37="python-3.7.1"
LATEST_35="python-3.5.6"
LATEST_34="python-3.4.9"
LATEST_27="python-2.7.15"
# Default Python Versions
# shellcheck source=bin/default_pythons
source "$BIN_DIR/default_pythons"
# Supported Python Branches
PY38="python-3.8"
PY37="python-3.7"
PY36="python-3.6"
PY35="python-3.5"
......@@ -68,8 +64,7 @@ DEFAULT_PYTHON_STACK="cedar-14"
# If pip doesn't match this version (the version we install), run the installer.
PIP_UPDATE="9.0.2"
export DEFAULT_PYTHON_VERSION DEFAULT_PYTHON_STACK PIP_UPDATE
export LATEST_27 LATEST_36 LATEST_37 LATEST_35 LATEST_34
export DEFAULT_PYTHON_STACK PIP_UPDATE
export PY37 PY36 PY35 PY27 PY34
# Common Problem Warnings:
......
#!/usr/bin/env bash
DEFAULT_PYTHON_VERSION="python-3.6.9"
LATEST_38="python-3.8.0"
LATEST_37="python-3.7.5"
LATEST_36="python-3.6.9"
LATEST_35="python-3.5.7"
LATEST_34="python-3.4.10"
LATEST_27="python-2.7.17"
export DEFAULT_PYTHON_VERSION LATEST_38 LATEST_37 LATEST_36 LATEST_35 LATEST_34 LATEST_27
......@@ -26,9 +26,9 @@ if (pip-grep -s requirements.txt GDAL gdal pygdal &> /dev/null) then
mkdir -p .heroku/vendor
# Download and extract cryptography into target vendor directory.
curl "$VENDORED_GDAL" -s | tar zxv -C .heroku/vendor &> /dev/null
mcount "steps.vendor.gdal"
fi
GDAL=$(pwd)/vendor
export GDAL
fi
......@@ -22,6 +22,7 @@ source "$BIN_DIR/utils"
# If GDAL exists within requirements, use vendored gdal.
if [[ "$BUILD_WITH_GEO_LIBRARIES" ]]; then
mcount "buildvar.BUILD_WITH_GEO_LIBRARIES"
if [ ! -f ".heroku/vendor/bin/proj" ]; then
echo "-----> Bootstrapping gdal, geos, proj."
......@@ -31,9 +32,11 @@ if [[ "$BUILD_WITH_GEO_LIBRARIES" ]]; then
curl "$VENDORED_GEOS" -s | tar zxv -C .heroku/vendor &> /dev/null
curl "$VENDORED_PROJ" -s | tar zxv -C .heroku/vendor &> /dev/null
mcount "steps.vendor.geo_libs"
# Copy libjasper from build image to slug.
if [[ "$STACK" == "heroku-16" ]]; then
cp /usr/lib/x86_64-linux-gnu/libjasper.so* ".heroku/vendor/lib/."
mcount "steps.vendor.libjasper"
fi
fi
......
......@@ -4,6 +4,6 @@
if [[ -f "requirements.txt" ]]; then
if (grep -Fiq "hg+" requirements.txt) then
/app/.heroku/python/bin/pip install mercurial | cleanup | indent
mcount "steps.mercurial"
fi
fi
......@@ -27,6 +27,8 @@ if sp-grep -s nltk; then
python -m nltk.downloader -d "$BUILD_DIR/.heroku/python/nltk_data" "${nltk_packages[@]}" | indent
set_env NLTK_DATA "/app/.heroku/python/nltk_data"
mcount "buildvar.NLTK_PACKAGES_DEFINITION"
mcount "steps.nltk"
else
puts-warn "'nltk.txt' not found, not downloading any corpora"
puts-warn "Learn more: https://devcenter.heroku.com/articles/python-nltk"
......
......@@ -38,7 +38,9 @@ if [ ! "$SKIP_PIP_INSTALL" ]; then
mcount "failure.none-version"
fi
if [ ! -f "$BUILD_DIR/.heroku/python/bin/pip" ]; then
exit 1
fi
/app/.heroku/python/bin/pip install -r "$BUILD_DIR/requirements.txt" --exists-action=w --src=/app/.heroku/src --disable-pip-version-check --no-cache-dir 2>&1 | tee "$WARNINGS_LOG" | cleanup | indent
PIP_STATUS="${PIPESTATUS[0]}"
set -e
......
......@@ -13,7 +13,7 @@ if [ ! "$SKIP_PIP_INSTALL" ]; then
if ! pip-diff --stale requirements-declared.txt requirements.txt --exclude setuptools pip wheel > .heroku/python/requirements-stale.txt; then
mount "failure.bad-requirements"
mcount "failure.bad-requirements"
fi
rm -fr requirements-declared.txt
......
......@@ -26,7 +26,7 @@ fi
if [ ! "$SKIP_PIPENV_INSTALL" ]; then
# Pipenv support (Generate requriements.txt with pipenv).
# Pipenv support (Generate requirements.txt with pipenv).
if [[ -f Pipfile ]]; then
# Measure that we're using Pipenv.
mcount "tool.pipenv"
......@@ -60,10 +60,16 @@ if [ ! "$SKIP_PIPENV_INSTALL" ]; then
# avoid this eager behavior.
/app/.heroku/python/bin/pip install pipenv==$PIPENV_VERSION --upgrade --upgrade-strategy only-if-needed &> /dev/null
# Install the test dependencies, for CI.
if [ "$INSTALL_TEST" ]; then
puts-step "Installing test dependencies…"
/app/.heroku/python/bin/pipenv install --dev --system --deploy 2>&1 | cleanup | indent
# Install the dependencies.
if [[ ! -f Pipfile.lock ]]; then
elif [[ ! -f Pipfile.lock ]]; then
puts-step "Installing dependencies with Pipenv $PIPENV_VERSION…"
/app/.heroku/python/bin/pipenv install --system --skip-lock 2>&1 | indent
else
pipenv-to-pip Pipfile.lock > requirements.txt
"$BIN_DIR/steps/pip-uninstall"
......@@ -73,12 +79,6 @@ if [ ! "$SKIP_PIPENV_INSTALL" ]; then
puts-step "Installing dependencies with Pipenv $PIPENV_VERSION…"
/app/.heroku/python/bin/pipenv install --system --deploy 2>&1 | indent
fi
# Install the test dependencies, for CI.
if [ "$INSTALL_TEST" ]; then
puts-step "Installing test dependencies…"
/app/.heroku/python/bin/pipenv install --dev --system --deploy 2>&1 | cleanup | indent
fi
fi
else
export SKIP_PIP_INSTALL=1
......
......@@ -29,6 +29,7 @@ if (pip-grep -s requirements.txt pylibmc &> /dev/null) then
mkdir -p .heroku/vendor
# Download and extract libmemcached into target vendor directory.
curl "$VENDORED_MEMCACHED" -s | tar zxv -C .heroku/vendor &> /dev/null
mcount "steps.vendor.pylibmc"
fi
LIBMEMCACHED=$(pwd)/vendor
......
......@@ -11,6 +11,13 @@ SECURITY_UPDATE="Python has released a security update! Please consider upgradin
# check if runtime exists
if curl --output /dev/null --silent --head --fail "$VENDORED_PYTHON"; then
if [[ "$PYTHON_VERSION" == $PY38* ]]; then
# do things to alert the user of security release available
if [ "$PYTHON_VERSION" != "$LATEST_38" ]; then
puts-warn "$SECURITY_UPDATE" "$LATEST_38"
echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes"
fi
fi
if [[ "$PYTHON_VERSION" == $PY37* ]]; then
# do things to alert the user of security release available
if [ "$PYTHON_VERSION" != "$LATEST_37" ]; then
......@@ -97,6 +104,15 @@ if [ ! "$SKIP_INSTALL" ]; then
hash -r
fi
# Heroku uses the get-pip utility maintained by the Python community to vendor Pip.
# https://github.com/pypa/get-pip
GETPIP="https://lang-python.s3.amazonaws.com/etc/get-pip.py"
if ! curl -s "${GETPIP}" -o "$ROOT_DIR/get-pip.py" &> /dev/null; then
mcount "failure.python.get-pip"
echo "Failed to pull down get-pip"
exit 1
fi
# If Pip isn't up to date:
if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_UPDATE* ]]; then
......@@ -107,9 +123,8 @@ if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_UPDATE* ]]; then
rm -fr /app/.heroku/python/lib/python*/site-packages/pip-*
rm -fr /app/.heroku/python/lib/python*/site-packages/setuptools-*
/app/.heroku/python/bin/python "$ROOT_DIR/vendor/get-pip.py" pip=="$PIP_UPDATE" &> /dev/null
/app/.heroku/python/bin/python "$ROOT_DIR/get-pip.py" pip=="$PIP_UPDATE" &> /dev/null
/app/.heroku/python/bin/pip install "$ROOT_DIR/vendor/setuptools-39.0.1-py2.py3-none-any.whl" &> /dev/null
fi
set -e
......
......@@ -4,7 +4,13 @@
source "$BIN_DIR/utils"
sqlite3_version() {
SQLITE3_VERSION=${SQLITE3_VERSION:-$(dpkg -s libsqlite3-0 | grep Version | sed 's/Version: //')}
if [ "$STACK" = "cedar-14" ]; then
SQLITE3_VERSION="3.8.2-1ubuntu2.2"
elif [ "$STACK" = "heroku-16" ]; then
SQLITE3_VERSION="3.11.0-1ubuntu1.2"
else
SQLITE3_VERSION=${SQLITE3_VERSION:-$(dpkg -s libsqlite3-0 | grep Version | sed 's/Version: //')}
fi
export SQLITE3_VERSION
}
......
# Python Buildpack Binaries
For Cedar-14 stack
------------------
## Building the Docker Images
To get started with it, create an app on Heroku inside a clone of this repository, and set your S3 config vars:
**After every change to your formulae, perform the following** from the root of the Git repository (not from `builds/`) to rebuild the images for each stack:
$ heroku create --buildpack https://github.com/heroku/heroku-buildpack-python#not-heroku
$ heroku config:set WORKSPACE_DIR=builds
$ heroku config:set AWS_ACCESS_KEY_ID=<your_aws_key>
$ heroku config:set AWS_SECRET_ACCESS_KEY=<your_aws_secret>
$ heroku config:set S3_BUCKET=<your_s3_bucket_name>
$ docker build --pull --tag heroku-python-build-cedar-14 --file $(pwd)/builds/cedar-14.Dockerfile .
$ docker build --pull --tag heroku-python-build-heroku-16 --file $(pwd)/builds/heroku-16.Dockerfile .
$ docker build --pull --tag heroku-python-build-heroku-18 --file $(pwd)/builds/heroku-18.Dockerfile .
## Using the Image
Then, shell into an instance and run a build by giving the name of the formula inside `builds`:
You can e.g. `bash` into each of the images you built using their tag:
$ heroku run bash
Running `bash` attached to terminal... up, run.6880
~ $ bob build runtimes/python-2.7.6
docker run --rm -ti heroku-python-build-cedar-14 bash
docker run --rm -ti heroku-python-build-heroku-16 bash
docker run --rm -ti heroku-python-build-heroku-18 bash
Fetching dependencies... found 2:
- libraries/sqlite
You then have a shell where you can run `bob build`, `bob deploy`, and so forth. You can of course also invoke these programs directly with `docker run`:
Building formula runtimes/python-2.7.6:
=== Building Python 2.7.6
Fetching Python v2.7.6 source...
Compiling...
docker run --rm -ti heroku-python-build-heroku-18 bob build runtimes/python-2.7.15
If this works, run `bob deploy` instead of `bob build` to have the result uploaded to S3 for you.
In order to `bob deploy`, AWS credentials must be set up, as well as name and prefix of your custom S3 bucket (unless you're deploying to the Heroku production buckets that are pre-defined in each `Dockerfile`); see next section for details.
To speed things up drastically, it'll usually be a good idea to `heroku run bash --size PX` instead.
## Configuration
For Heroku-16 stack
-------------------
File `dockerenv.default` contains a list of required env vars; most of these have default values defined in `Dockerfile`. You can copy this file to a location outside the buildpack and modify it with the values you desire and pass its location with `--env-file`, or pass the env vars to `docker run` using `--env`.
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!
Out of the box, each `Dockerfile` has the correct values predefined for `S3_BUCKET`, `S3_PREFIX`, and `S3_REGION`. If you're building your own packages, you'll likely want to change `S3_BUCKET` and `S3_PREFIX` to match your info. Instead of setting `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` into that file, you may also pass them to `docker run` through the environment, or explicitly using `--env`, in order to prevent accidental commits of credentials.
### Passing AWS credentials to the container
Enjoy :)
If you want to deploy packages and thus need to pass `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`, you can either pass them explicitly, through your environment, or through an env file.
#### Passing credentials explicitly
docker run --rm -ti -e AWS_ACCESS_KEY_ID=... -e AWS_SECRET_ACCESS_KEY=... heroku-python-build-heroku-18 bash
#### Passing credentials through the environment
The two environment variables `AWS_ACCESS_KEY_ID`and `AWS_SECRET_ACCESS_KEY` are defined in `builds/dockerenv.default`, without values. This will cause Docker to "forward" values for these variables from the current environment, so you can pass them in:
AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... docker run --rm -ti --env-file=builds/dockerenv.default heroku-python-build-heroku-18 bash
or
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
docker run --rm -ti --env-file=builds/dockerenv.default heroku-python-build-heroku-18 bash
#### Passing credentials through a separate env file
This method is the easiest for users who want to build packages in their own S3 bucket, as they will have to adjust the `S3_BUCKET` and `S3_PREFIX` environment variable values anyway from their default values.
For this method, it is important to keep the credentials file in a location outside the buildpack, so that your credentials aren't accidentally committed. Copy `builds/dockerenv.default` **to a safe location outside the buildpack directory**, and insert your values for `AWS_ACCESS_KEY_ID`and `AWS_SECRET_ACCESS_KEY`.
docker run --rm -ti --env-file=../SOMEPATHOUTSIDE/s3.env heroku-python-build-heroku-18 bash
FROM heroku/heroku:18-build
FROM heroku/cedar:14
WORKDIR /app
ENV WORKSPACE_DIR="/app/builds" \
S3_BUCKET="lang-python" \
S3_PREFIX="heroku-18/"
S3_PREFIX="cedar-14/" \
DEBIAN_FRONTEND=noninteractive \
STACK="cedar-14"
RUN apt-get update && apt-get install -y python-pip && rm -rf /var/lib/apt/lists/*
COPY requirements.txt /app/
RUN pip install --disable-pip-version-check --no-cache-dir -r /app/requirements.txt
RUN pip install -r /app/requirements.txt
COPY . /app
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
S3_BUCKET
S3_PREFIX
S3_REGION
......@@ -3,7 +3,9 @@ FROM heroku/heroku:16-build
WORKDIR /app
ENV WORKSPACE_DIR="/app/builds" \
S3_BUCKET="lang-python" \
S3_PREFIX="heroku-16/"
S3_PREFIX="heroku-16/" \
DEBIAN_FRONTEND=noninteractive \
STACK="heroku-16"
RUN apt-get update && apt-get install -y python-pip && rm -rf /var/lib/apt/lists/*
......
FROM heroku/heroku:18-build.v16
WORKDIR /app
ENV WORKSPACE_DIR="/app/builds" \
S3_BUCKET="lang-python" \
S3_PREFIX="heroku-18/" \
DEBIAN_FRONTEND=noninteractive \
STACK="heroku-18"
RUN apt-get update && apt-get install --no-install-recommends -y python-pip-whl=9.0.1-2 python-pip=9.0.1-2 python-setuptools python-wheel && rm -rf /var/lib/apt/lists/*
COPY requirements.txt /app/
RUN pip install --disable-pip-version-check --no-cache-dir -r /app/requirements.txt
COPY . /app
#!/usr/bin/env bash
# fail hard
set -o pipefail
# fail harder
set -eu
OUT_PREFIX=$1
dep_formula=${0#$WORKSPACE_DIR/} # this is the original script, e.g. pypy-5.3.1
dep_name=$(basename $BASH_SOURCE) # this is us
dep_version=${dep_formula##*"/${dep_name}-"} # "subtract" our name from full version name
dep_package=${dep_name}2-v${dep_version} # it's always "pypy2-…"
dep_dirname=${dep_package}-linux64
dep_archive_name=${dep_dirname}.tar.bz2
dep_url=https://bitbucket.org/pypy/pypy/downloads/${dep_archive_name}
echo "Building PyPy…"
curl -L "${dep_url}" | tar jx -C "${OUT_PREFIX}" --strip-components 1 # extract to $OUT_PREFIX, drop the first directory level, which is the archive name