Skip to content

Commit

Permalink
Add initial working buildpack
Browse files Browse the repository at this point in the history
Co-authored-by: Eoghan Kelleher <[email protected]>
  • Loading branch information
sneal and eoghank committed Dec 16, 2024
0 parents commit e943cdd
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# workspace file
.idea/
.vscode/

# OS files
.DS_Store
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Cloud Foundry OpenSSL Buildpack

A Cloud Foundry [buildpack](http://docs.cloudfoundry.org/buildpacks/) for using OpenSSL 1.1 on cflinuxfs4.

This supply buildpack is meant to be used with the .NET buildpack as the final buildpack. This buildpack sets the
the `LD_LIBRARY_PATH` and the `CLR_OPENSSL_VERSION_OVERRIDE` environment variables needed by .NET apps to be able
to use the non-default OpenSSL version. This buildpack may work with other final buildpacks, but is currently
untested.

### Usage

Just add this buildpack to your app's list of existing buildpacks. For example:

```yaml
---
applications:
- name: cf-dotnet-webapp
buildpacks:
- openssl_buildpack
- dotnet_core_buildpack
memory: 1G
stack: cflinuxfs4
```
### Building the Buildpack
Since this buildpack is nothing more than a bash script, just run the `create_buildpack.sh` script to package and upload the buildpack to CF. This will increment the version, delete the old version of the buildpack from CF, then create a new version of it.

1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0
2 changes: 2 additions & 0 deletions bin/detect
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#! /bin/sh
exit 0
36 changes: 36 additions & 0 deletions bin/supply
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
set -euo pipefail

# Variables passed to the supply script
BUILD_DIR=$1 # Application build directory
CACHE_DIR=$2 # Buildpack's cache directory
DEPS_DIR=$3 # Root directory for all buildpack dependencies
DEPS_IDX=$4 # Index for this buildpack's dependencies

# Calculate the current buildpack's dependency directory
DEP_DIR="$DEPS_DIR/$DEPS_IDX"

# Get the buildpack's base directory
BUILDPACK_DIR=$(dirname "$0")/..

# Buildpack banner
VERSION=$(cat "$BUILDPACK_DIR/VERSION")
echo "-----> OpenSSL Buildpack version $VERSION"
echo "-----> Supplying OpenSSL 1.1"

# Create the necessary directories in the dependencies folder
echo "Creating openssl folder"
mkdir -p "$DEP_DIR/openssl"

echo "Extracting openssl files"
tar -xzvf "$BUILDPACK_DIR/dependencies/openssl1.1.1.tar.gz" -C "$DEP_DIR/openssl/"

# Add runtime environment variables to .profile.d/
mkdir -p "$BUILD_DIR/.profile.d"
cat <<EOF > "$BUILD_DIR/.profile.d/set_ssl_path.sh"
#!/bin/bash
export LD_LIBRARY_PATH="/home/vcap/deps/$DEPS_IDX/openssl/openssl-1.1.1;\$LD_LIBRARY_PATH"
export CLR_OPENSSL_VERSION_OVERRIDE='1.1'
EOF

chmod a+x "$BUILD_DIR/.profile.d/set_ssl_path.sh"
16 changes: 16 additions & 0 deletions create_buildpack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /usr/bin/env bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

VERSION=$(cat "$SCRIPT_DIR/VERSION")
IFS='.' read -r MAJOR MINOR <<< "$VERSION"
MINOR=$((MINOR + 1))
NEXTVERSION="$MAJOR.$MINOR"

pushd "$SCRIPT_DIR"
zip -r "/tmp/openssl_buildpack-v$NEXTVERSION.zip" . -x .DS_Store
popd
cf delete-buildpack openssl_buildpack -f
cf create-buildpack openssl_buildpack "/tmp/openssl_buildpack-v$NEXTVERSION.zip" 99

echo "$NEXTVERSION" > "$SCRIPT_DIR/VERSION"
Binary file added dependencies/openssl1.1.1.tar.gz
Binary file not shown.
12 changes: 12 additions & 0 deletions manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
default_versions: []
dependencies: []
dependency_deprecation_dates: []
include_files:
- README.md
- VERSION
- bin/supply
- bin/detect
- manifest.yml
- dependencies/openssl1.1.1.tar.gz
language: openssl
stack: cflinuxfs4

0 comments on commit e943cdd

Please sign in to comment.