Sign inSign up

rapid7/cpython

By rapid7

•Updated about 4 years ago

Cloud Native Buildpack for installing python with support for all stacks

Image
0

300

rapid7/cpython repository overview

⁠rapid7/cpython

This is a fork of the paketo-buildpacks/cpython buildpack with support for all stacks. The buildpack.toml file had to be modified to specify a version (9.9.9) in order to package up the buildpack.

See this pull request for details on how this buildpack works. https://github.com/paketo-buildpacks/cpython/pull/398⁠

⁠What is a buildpack?

See: https://buildpacks.io⁠

⁠How to use this buildpack

⁠Clone the paketo samples repo

This contains sample applications for different languages that can be used to app containers.

git clone https://github.com/paketo-buildpacks/samples.git

We will be using the example app located here: samples/python/no_package_manager

⁠Build a container using this buildpack on a custom amazonlinux stack

The amazonlinux builder does not include any buildpacks, so we need to specify all buildpacks.

--env BP_LOG_LEVEL=DEBUG enables configure and make output (omit for less verbose build)

pack build no-package-manager-sample --path samples/python/no_package_manager \
  --builder rapid7/amazonlinux-builder:base \
  --buildpack rapid7/cpython:latest \
  --buildpack paketo-buildpacks/python-start \
  --buildpack paketo-buildpacks/procfile \
  --env BP_LOG_LEVEL=DEBUG \
  --env BP_CPYTHON_VERSION=3.10.6

⁠Show the buildpacks used to build the container

pack inspect no-package-manager-sample

⁠Verify the app container works

The sample app is a web app using standard http.server and socketserver modules.

See samples/python/no_package_manager/README.md for instructions on running the container.

⁠Verify the container has python installed

docker run --rm -it --entrypoint launcher no-package-manager-sample python --version

⁠How this was built

# Clone the forked cpython repo and correct branch, and build binaries (assumes go is installed)
git clone -b support-all-stacks [email protected]:rapid7/cpython.git
cd cpython
./scripts/build.sh 

mkdir to-be-packaged

# Move the buildpack binaries to the to-be-packaged directory
mv bin to-be-packaged/

# Create a package.toml file that points to the current directory
cat <<EOF > to-be-packaged/package.toml
[buildpack]
uri = "file://./"
EOF

# Add a version so we can package the buildpack as an image
cat buildpack.toml | yj -tj | jq '.buildpack += {version: "9.9.9"}' | yj -jt > to-be-packaged/buildpack.toml

cd to-be-packaged

# Create a buildpack image and publish it to docker hub
pack buildpack package rapid7/cpython:latest --config package.toml --publish

# Clean up so there are no changes in the repo
cd .. && rm -r to-be-packaged

Tag summary

Content type

Image

Digest

sha256:659152cc9…

Size

9.5 MB

Last updated

about 4 years ago

docker pull rapid7/cpython