Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ Official buildpack documentation can be found here: [php buildpack docs](http://
#### Option 1: Using the `package.sh` script
1. Run `./scripts/package.sh [ --uncached | --cached ] [ --stack=STACK ]`

This requires that you have `docker` installed on your local machine, as it
will run packaging setup within a `ruby` image.
This script automatically installs the Go-based `buildpack-packager` and builds the buildpack.

#### Option 2: Manually use the `buildpack-packager`
1. Make sure you have fetched submodules
Expand All @@ -29,16 +28,16 @@ will run packaging setup within a `ruby` image.
git checkout v4.4.2 # or whatever version you want, see releases page for available versions
```

1. Get latest buildpack dependencies, this will require having Ruby 3.0 or running in a Ruby 3.0 container image
1. Install the Go-based buildpack-packager

```shell
BUNDLE_GEMFILE=cf.Gemfile bundle
go install github.com/cloudfoundry/libbuildpack/packager/buildpack-packager@latest
```

1. Build the buildpack. Please note that the PHP buildpack still uses the older Ruby based buildpack packager. This is different than most of the other buildpacks which use a newer Golang based buildpack packager. You must use the Ruby based buildpack packager with the PHP buildpack.
1. Build the buildpack

```shell
BUNDLE_GEMFILE=cf.Gemfile bundle exec buildpack-packager [ --uncached | --cached ] [ --any-stack | --stack=STACK ]
buildpack-packager build [ -uncached | -cached ] [ -any-stack | -stack=STACK ]
```

1. Use in Cloud Foundry
Expand Down
5 changes: 0 additions & 5 deletions cf.Gemfile

This file was deleted.

43 changes: 0 additions & 43 deletions cf.Gemfile.lock

This file was deleted.

4 changes: 0 additions & 4 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ exclude_files:
- ".bin/"
- log/
- tests/
- cf.Gemfile
- cf.Gemfile.lock
- bin/package
- buildpack-packager/
- requirements.txt
Expand All @@ -20,8 +18,6 @@ default_versions:
version: 8.1.32
- name: httpd
version: 2.4.63
- name: newrelic
version: 10.21.0.11
- name: nginx
version: 1.27.5
- name: composer
Expand Down
28 changes: 28 additions & 0 deletions scripts/.util/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,34 @@ function util::tools::ginkgo::install() {
fi
}

function util::tools::buildpack-packager::install() {
local dir
while [[ "${#}" != 0 ]]; do
case "${1}" in
--directory)
dir="${2}"
shift 2
;;

*)
util::print::error "unknown argument \"${1}\""
esac
done

mkdir -p "${dir}"
util::tools::path::export "${dir}"

if [[ ! -f "${dir}/buildpack-packager" ]]; then
util::print::title "Installing buildpack-packager"

pushd /tmp > /dev/null || return
GOBIN="${dir}" \
go install \
github.com/cloudfoundry/libbuildpack/packager/buildpack-packager@latest
popd > /dev/null || return
fi
}

function util::tools::jq::install() {
local dir
while [[ "${#}" != 0 ]]; do
Expand Down
8 changes: 1 addition & 7 deletions scripts/brats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ function main() {
source "${ROOTDIR}/scripts/.util/tools.sh"

util::tools::ginkgo::install --directory "${ROOTDIR}/.bin"

# set up buildpack-packager
# apt-get install ruby
gem install bundler
export BUNDLE_GEMFILE=cf.Gemfile
bundle install

util::tools::buildpack-packager::install --directory "${ROOTDIR}/.bin"

GINKGO_NODES=${GINKGO_NODES:-3}
GINKGO_ATTEMPTS=${GINKGO_ATTEMPTS:-1}
Expand Down
2 changes: 1 addition & 1 deletion scripts/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function main() {
)
fi

#util::tools::buildpack-packager::install --directory "${ROOTDIR}/.bin"
util::tools::buildpack-packager::install --directory "${ROOTDIR}/.bin"
util::tools::cf::install --directory "${ROOTDIR}/.bin"

for row in "${matrix[@]}"; do
Expand Down
50 changes: 17 additions & 33 deletions scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ set -o pipefail
ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
readonly ROOTDIR

## shellcheck source=SCRIPTDIR/.util/tools.sh
#source "${ROOTDIR}/scripts/.util/tools.sh"
#
# shellcheck source=SCRIPTDIR/.util/tools.sh
source "${ROOTDIR}/scripts/.util/tools.sh"

# shellcheck source=SCRIPTDIR/.util/print.sh
source "${ROOTDIR}/scripts/.util/print.sh"

Expand Down Expand Up @@ -92,43 +92,27 @@ function package::buildpack() {
echo "${version}" > "${ROOTDIR}/VERSION"
fi

mkdir -p "$(dirname "${output}")"

util::tools::buildpack-packager::install --directory "${ROOTDIR}/.bin"

echo "Building buildpack (version: ${version}, stack: ${stack}, cached: ${cached}, output: ${output})"

local stack_flag
stack_flag="--any-stack"
if [[ "${stack}" != "any" ]]; then
stack_flag="--stack=${stack}"
fi

local cached_flag
cached_flag="--uncached"
if [[ "${cached}" == "true" ]]; then
cached_flag="--cached"
fi

pushd "${ROOTDIR}" &> /dev/null
cat <<EOF > Dockerfile
FROM ruby:3.0
RUN apt-get update && apt-get install -y zip
ADD cf.Gemfile .
ADD cf.Gemfile.lock .
ENV BUNDLE_GEMFILE=cf.Gemfile
RUN bundle install
ENTRYPOINT ["bundle", "exec", "buildpack-packager"]
EOF
docker build -t buildpack-packager . &> /dev/null
local file
file="$(
buildpack-packager build \
"--version=${version}" \
"--cached=${cached}" \
"${stack_flag}" \
| xargs -n1 | grep -e '\.zip$'
)"

docker run --rm -v "${ROOTDIR}":/buildpack -w /buildpack buildpack-packager "${stack_flag}" ${cached_flag} &> /dev/null

popd &> /dev/null

rm -f "${ROOTDIR}/Dockerfile"

file="$(ls "${ROOTDIR}" | grep -i 'php.*zip' )"
if [[ -z "${file}" ]]; then
util::print::error "failed to find zip file in ${ROOTDIR}"
fi

mkdir -p "$(dirname "${output}")"
echo "Moving ${file} to ${output}"
mv "${file}" "${output}"
}

Expand Down
Loading