Skip to content

Commit

Permalink
use tgz to distribute binaries (ryandotsmith#59)
Browse files Browse the repository at this point in the history
* start building archives

* use mime.types from stack archive

* build new archives and cleanup old binaries

* update bin/compile

* update bin/compile

* update changelog

* Update changelog

* update changelog
  • Loading branch information
beanieboi authored Jul 20, 2020
1 parent 41dddf4 commit 60e21ce
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 94 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ build: build-cedar-14 build-heroku-16 build-heroku-18 build-heroku-20

build-cedar-14:
@echo "Building nginx in Docker for cedar-14..."
@docker run -v $(shell pwd):/buildpack --rm -it -e "STACK=cedar-14" -e "NGINX_VERSION=1.9.5" -e "PCRE_VERSION=8.37" -e "HEADERS_MORE_VERSION=0.261" -w /buildpack heroku/cedar:14 scripts/build_nginx /buildpack/bin/nginx-cedar-14 /buildpack/bin/nginx-debug-cedar-14
@docker run -v $(shell pwd):/buildpack --rm -it -e "STACK=cedar-14" -e "NGINX_VERSION=1.9.5" -e "PCRE_VERSION=8.37" -e "HEADERS_MORE_VERSION=0.261" -w /buildpack heroku/cedar:14 scripts/build_nginx /buildpack/nginx-cedar-14.tgz

build-heroku-16:
@echo "Building nginx in Docker for heroku-16..."
@docker run -v $(shell pwd):/buildpack --rm -it -e "STACK=heroku-16" -e "NGINX_VERSION=1.9.5" -e "PCRE_VERSION=8.37" -e "HEADERS_MORE_VERSION=0.261" -w /buildpack heroku/heroku:16-build scripts/build_nginx /buildpack/bin/nginx-heroku-16 /buildpack/bin/nginx-debug-heroku-16
@docker run -v $(shell pwd):/buildpack --rm -it -e "STACK=heroku-16" -e "NGINX_VERSION=1.9.5" -e "PCRE_VERSION=8.37" -e "HEADERS_MORE_VERSION=0.261" -w /buildpack heroku/heroku:16-build scripts/build_nginx /buildpack/nginx-heroku-16.tgz

build-heroku-18:
@echo "Building nginx in Docker for heroku-18..."
@docker run -v $(shell pwd):/buildpack --rm -it -e "STACK=heroku-18" -w /buildpack heroku/heroku:18-build scripts/build_nginx /buildpack/bin/nginx-heroku-18 /buildpack/bin/nginx-debug-heroku-18
@docker run -v $(shell pwd):/buildpack --rm -it -e "STACK=heroku-18" -w /buildpack heroku/heroku:18-build scripts/build_nginx /buildpack/nginx-heroku-18.tgz

build-heroku-20:
@echo "Building nginx in Docker for heroku-20..."
@docker run -v $(shell pwd):/buildpack --rm -it -e "STACK=heroku-20" -w /buildpack heroku/heroku:20-build scripts/build_nginx /buildpack/bin/nginx-heroku-20 /buildpack/bin/nginx-debug-heroku-20
@docker run -v $(shell pwd):/buildpack --rm -it -e "STACK=heroku-20" -w /buildpack heroku/heroku:20-build scripts/build_nginx /buildpack/nginx-heroku-20.tgz

shell:
@echo "Opening heroku-18 shell..."
Expand Down
40 changes: 28 additions & 12 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,47 @@

set -e

mkdir -p "$1/bin/"
cp "bin/nginx-$STACK" "$1/bin/nginx"
cp "bin/nginx-debug-$STACK" "$1/bin/nginx-debug"
nginx_version=$(./bin/nginx-$STACK -V 2>&1 | head -1 | awk '{ print $NF }')
# clean up leaking environment
unset GIT_DIR

# parse and derive params
BUILD_DIR=$1
CACHE_DIR=$2
BUILDPACK_DIR="$(dirname "$(dirname "$0")")"

mkdir -p "$BUILD_DIR/bin/"
mkdir -p "$BUILD_DIR/nginx"
tar -zxvf "nginx-$STACK".tgz -C "$BUILD_DIR/nginx"

cp "$BUILD_DIR/nginx/nginx" "$BUILD_DIR/bin/nginx"
cp "$BUILD_DIR/nginx/nginx-debug" "$BUILD_DIR/bin/nginx-debug"

nginx_version=$($BUILD_DIR/bin/nginx -V 2>&1 | head -1 | awk '{ print $NF }')
echo "-----> nginx-buildpack: Installed ${nginx_version} to app/bin"
cp bin/start-nginx "$1/bin/"
cp bin/start-nginx "$BUILD_DIR/bin/"
echo '-----> nginx-buildpack: Added start-nginx to app/bin'
cp bin/start-nginx-debug "$1/bin/"
cp bin/start-nginx-debug "$BUILD_DIR/bin/"
echo '-----> nginx-buildpack: Added start-nginx-debug to app/bin'
cp bin/start-nginx-solo "$1/bin/"
cp bin/start-nginx-solo "$BUILD_DIR/bin/"
echo '-----> nginx-buildpack: Added start-nginx-solo to app/bin'

mkdir -p "$1/config"
mkdir -p "$BUILD_DIR/config"

if [[ ! -f $1/config/mime.types ]]; then
cp config/mime.types "$1/config/"
if [[ ! -f $BUILD_DIR/config/mime.types ]]; then
cp "$BUILD_DIR/nginx/mime.types" "$BUILD_DIR/config/"
echo '-----> nginx-buildpack: Default mime.types copied to app/config/'
else
echo '-----> nginx-buildpack: Custom mime.types found in app/config.'
fi

if [[ ! -f $1/config/nginx.conf.erb ]]; then
cp config/nginx.conf.erb "$1/config/"
if [[ ! -f $BUILD_DIR/config/nginx.conf.erb ]]; then
cp config/nginx.conf.erb "$BUILD_DIR/config/"
echo '-----> nginx-buildpack: Default config copied to app/config.'
else
echo '-----> nginx-buildpack: Custom config found in app/config.'
fi

# cleanup
rm -r "$BUILD_DIR/nginx"

exit 0
Binary file removed bin/nginx-cedar-14
Binary file not shown.
Binary file removed bin/nginx-debug-cedar-14
Binary file not shown.
Binary file removed bin/nginx-debug-heroku-16
Binary file not shown.
Binary file removed bin/nginx-debug-heroku-18
Binary file not shown.
Binary file removed bin/nginx-debug-heroku-20
Binary file not shown.
Binary file removed bin/nginx-heroku-16
Binary file not shown.
Binary file removed bin/nginx-heroku-18
Binary file not shown.
Binary file removed bin/nginx-heroku-20
Binary file not shown.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## unreleased
### Added
- [all] move to tgz to distribute binaries
- [all] update mime.types to reflect the version that is included in the nginx distrubition

## [1.4] - 2020-05-05
### Added
- [all] add nginx-debug binary
Expand Down
76 changes: 0 additions & 76 deletions config/mime.types

This file was deleted.

Binary file added nginx-cedar-14.tgz
Binary file not shown.
Binary file added nginx-heroku-16.tgz
Binary file not shown.
Binary file added nginx-heroku-18.tgz
Binary file not shown.
Binary file added nginx-heroku-20.tgz
Binary file not shown.
9 changes: 7 additions & 2 deletions scripts/build_nginx
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,10 @@ echo "Downloading $uuid4_url"
make install
)

cp /tmp/nginx/sbin/nginx $1
cp /tmp/nginx-debug/sbin/nginx $2
release_dir=$(mktemp -d /tmp/nginx.XXXXXXXXXX)

cp /tmp/nginx/sbin/nginx $release_dir/nginx
cp /tmp/nginx-debug/sbin/nginx $release_dir/nginx-debug
cp /tmp/nginx/conf/mime.types $release_dir/mime.types
tar -zcvf /tmp/nginx-"${STACK}".tgz -C $release_dir .
cp /tmp/nginx-"${STACK}".tgz $1

0 comments on commit 60e21ce

Please sign in to comment.