mirror of
https://github.com/kennethreitz/heroku-buildpack-python.git
synced 2026-06-05 15:00:19 +00:00
74a6c86c4f
It's often useful to be able to run a compile outside of the unit or Hatchet tests when developing the buildpack or debugging. Whilst running the compile locally inside Docker won't fully replicate a compile on the platform, for many use-cases it's close enough and importantly gives a faster development feedback loop, since buildpack changes don't have to be committed/pushed prior to triggering a compile. Closes @W-8436406@.
62 lines
2.4 KiB
Makefile
62 lines
2.4 KiB
Makefile
# These targets are not files
|
|
.PHONY: check test compile builder-image buildenv deploy-runtimes tools
|
|
|
|
STACK ?= heroku-18
|
|
STACKS ?= heroku-16 heroku-18 heroku-20
|
|
TEST_CMD ?= test/run-versions && test/run-features && test/run-deps
|
|
FIXTURE ?= test/fixtures/requirements-standard
|
|
ENV_FILE ?= builds/dockerenv.default
|
|
BUILDER_IMAGE_PREFIX := heroku-python-build
|
|
|
|
# Converts a stack name of `heroku-NN` to its build Docker image tag of `heroku/heroku:NN-build`.
|
|
STACK_IMAGE_TAG := heroku/$(subst -,:,$(STACK))-build
|
|
|
|
check:
|
|
@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/nltk bin/steps/pip-install bin/steps/pipenv bin/steps/pipenv-python-version bin/steps/python
|
|
@shellcheck -x bin/steps/hooks/*
|
|
|
|
test:
|
|
@echo "Running tests using: STACK=$(STACK) TEST_CMD='$(TEST_CMD)'"
|
|
@echo
|
|
@docker run --rm -it -v $(PWD):/buildpack:ro -e "STACK=$(STACK)" "$(STACK_IMAGE_TAG)" bash -c 'cp -r /buildpack /buildpack_test && cd /buildpack_test && $(TEST_CMD)'
|
|
@echo
|
|
|
|
compile:
|
|
@echo "Running compile using: STACK=$(STACK) FIXTURE=$(FIXTURE)"
|
|
@echo
|
|
@docker run --rm -it -v $(PWD):/src:ro -e "STACK=$(STACK)" -w /buildpack "$(STACK_IMAGE_TAG)" \
|
|
bash -c 'cp -r /src/{bin,vendor} /buildpack && cp -r /src/$(FIXTURE) /build && mkdir /cache /env && bin/compile /build /cache /env'
|
|
@echo
|
|
|
|
builder-image:
|
|
@echo "Generating binary builder image for $(STACK)..."
|
|
@echo
|
|
@docker build --pull -f builds/$(STACK).Dockerfile -t "$(BUILDER_IMAGE_PREFIX)-$(STACK)" .
|
|
@echo
|
|
|
|
buildenv: builder-image
|
|
@echo "Starting build environment for $(STACK)..."
|
|
@echo
|
|
@echo "Usage..."
|
|
@echo
|
|
@echo " $$ bob build runtimes/python-X.Y.Z"
|
|
@echo
|
|
@docker run --rm -it --env-file="$(ENV_FILE)" -v $(PWD)/builds:/app/builds "$(BUILDER_IMAGE_PREFIX)-$(STACK)" bash
|
|
|
|
deploy-runtimes:
|
|
ifndef RUNTIMES
|
|
$(error No runtimes specified! Use: "make deploy-runtimes RUNTIMES='python-X.Y.Z ...' [STACKS='heroku-18 ...'] [ENV_FILE=...]")
|
|
endif
|
|
@echo "Using: RUNTIMES='$(RUNTIMES)' STACKS='$(STACKS)' ENV_FILE='$(ENV_FILE)'"
|
|
@echo
|
|
@set -eu; for stack in $(STACKS); do \
|
|
$(MAKE) builder-image STACK=$${stack}; \
|
|
for runtime in $(RUNTIMES); do \
|
|
echo "Generating/deploying $${runtime} for $${stack}..."; \
|
|
echo; \
|
|
docker run --rm -it --env-file="$(ENV_FILE)" "$(BUILDER_IMAGE_PREFIX)-$${stack}" bob deploy "runtimes/$${runtime}"; \
|
|
echo; \
|
|
done; \
|
|
done
|