Skip to content

Commit e943cdd

Browse files
snealeoghank
andcommitted
Add initial working buildpack
Co-authored-by: Eoghan Kelleher <[email protected]>
0 parents  commit e943cdd

8 files changed

+101
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# workspace file
2+
.idea/
3+
.vscode/
4+
5+
# OS files
6+
.DS_Store

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Cloud Foundry OpenSSL Buildpack
2+
3+
A Cloud Foundry [buildpack](http://docs.cloudfoundry.org/buildpacks/) for using OpenSSL 1.1 on cflinuxfs4.
4+
5+
This supply buildpack is meant to be used with the .NET buildpack as the final buildpack. This buildpack sets the
6+
the `LD_LIBRARY_PATH` and the `CLR_OPENSSL_VERSION_OVERRIDE` environment variables needed by .NET apps to be able
7+
to use the non-default OpenSSL version. This buildpack may work with other final buildpacks, but is currently
8+
untested.
9+
10+
### Usage
11+
12+
Just add this buildpack to your app's list of existing buildpacks. For example:
13+
14+
```yaml
15+
---
16+
applications:
17+
- name: cf-dotnet-webapp
18+
buildpacks:
19+
- openssl_buildpack
20+
- dotnet_core_buildpack
21+
memory: 1G
22+
stack: cflinuxfs4
23+
```
24+
25+
### Building the Buildpack
26+
27+
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.
28+

VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0

bin/detect

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#! /bin/sh
2+
exit 0

bin/supply

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Variables passed to the supply script
5+
BUILD_DIR=$1 # Application build directory
6+
CACHE_DIR=$2 # Buildpack's cache directory
7+
DEPS_DIR=$3 # Root directory for all buildpack dependencies
8+
DEPS_IDX=$4 # Index for this buildpack's dependencies
9+
10+
# Calculate the current buildpack's dependency directory
11+
DEP_DIR="$DEPS_DIR/$DEPS_IDX"
12+
13+
# Get the buildpack's base directory
14+
BUILDPACK_DIR=$(dirname "$0")/..
15+
16+
# Buildpack banner
17+
VERSION=$(cat "$BUILDPACK_DIR/VERSION")
18+
echo "-----> OpenSSL Buildpack version $VERSION"
19+
echo "-----> Supplying OpenSSL 1.1"
20+
21+
# Create the necessary directories in the dependencies folder
22+
echo "Creating openssl folder"
23+
mkdir -p "$DEP_DIR/openssl"
24+
25+
echo "Extracting openssl files"
26+
tar -xzvf "$BUILDPACK_DIR/dependencies/openssl1.1.1.tar.gz" -C "$DEP_DIR/openssl/"
27+
28+
# Add runtime environment variables to .profile.d/
29+
mkdir -p "$BUILD_DIR/.profile.d"
30+
cat <<EOF > "$BUILD_DIR/.profile.d/set_ssl_path.sh"
31+
#!/bin/bash
32+
export LD_LIBRARY_PATH="/home/vcap/deps/$DEPS_IDX/openssl/openssl-1.1.1;\$LD_LIBRARY_PATH"
33+
export CLR_OPENSSL_VERSION_OVERRIDE='1.1'
34+
EOF
35+
36+
chmod a+x "$BUILD_DIR/.profile.d/set_ssl_path.sh"

create_buildpack.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#! /usr/bin/env bash
2+
3+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4+
5+
VERSION=$(cat "$SCRIPT_DIR/VERSION")
6+
IFS='.' read -r MAJOR MINOR <<< "$VERSION"
7+
MINOR=$((MINOR + 1))
8+
NEXTVERSION="$MAJOR.$MINOR"
9+
10+
pushd "$SCRIPT_DIR"
11+
zip -r "/tmp/openssl_buildpack-v$NEXTVERSION.zip" . -x .DS_Store
12+
popd
13+
cf delete-buildpack openssl_buildpack -f
14+
cf create-buildpack openssl_buildpack "/tmp/openssl_buildpack-v$NEXTVERSION.zip" 99
15+
16+
echo "$NEXTVERSION" > "$SCRIPT_DIR/VERSION"

dependencies/openssl1.1.1.tar.gz

1.95 MB
Binary file not shown.

manifest.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
default_versions: []
2+
dependencies: []
3+
dependency_deprecation_dates: []
4+
include_files:
5+
- README.md
6+
- VERSION
7+
- bin/supply
8+
- bin/detect
9+
- manifest.yml
10+
- dependencies/openssl1.1.1.tar.gz
11+
language: openssl
12+
stack: cflinuxfs4

0 commit comments

Comments
 (0)