mirror of
https://github.com/dokku/buildpack-nginx.git
synced 2025-04-10 13:18:22 +00:00
Move to supporting sigil templates by default
This commit is contained in:
parent
b9842399a3
commit
28d1a580cf
@ -25,7 +25,7 @@ heroku buildpacks:set https://github.com/dokku/buildpack-nginx.git
|
|||||||
|
|
||||||
You can override the nginx root via setting the `NGINX_ROOT` environment variable. This should be a relative path in your repository.
|
You can override the nginx root via setting the `NGINX_ROOT` environment variable. This should be a relative path in your repository.
|
||||||
|
|
||||||
You may completely override the built-in nginx config by placing an `nginx.conf.erb` file in the root, modeled after our own [`conf/nginx.config.erb`](https://github.com/dokku/buildpack-nginx/blob/master/conf/nginx.conf.erb). This will be used inside of the container, and not by the host Dokku instance.
|
You may completely override the built-in nginx config by placing an `nginx.conf.sigil` file in the root, modeled after our own [`conf/nginx.config.sigil`](https://github.com/dokku/buildpack-nginx/blob/master/conf/nginx.conf.sigil). This will be used inside of the container, and not by the host Dokku instance. See the [sigil project](https://github.com/gliderlabs/sigil) for more information concerning the sigil format.
|
||||||
|
|
||||||
## Credits and License
|
## Credits and License
|
||||||
|
|
||||||
|
20
bin/compile
20
bin/compile
@ -31,6 +31,7 @@ if [[ ! -e "$BUILD_DIR/www" ]]; then
|
|||||||
# Check for a copy the nginx conf file override to the build dir
|
# Check for a copy the nginx conf file override to the build dir
|
||||||
[[ -f "$BUILD_DIR/www/nginx.conf.erb" ]] && mv $BUILD_DIR/www/nginx.conf.erb $BUILD_DIR
|
[[ -f "$BUILD_DIR/www/nginx.conf.erb" ]] && mv $BUILD_DIR/www/nginx.conf.erb $BUILD_DIR
|
||||||
[[ -f "$BUILD_DIR/www/nginx.conf.sigil" ]] && mv $BUILD_DIR/www/nginx.conf.sigil $BUILD_DIR
|
[[ -f "$BUILD_DIR/www/nginx.conf.sigil" ]] && mv $BUILD_DIR/www/nginx.conf.sigil $BUILD_DIR
|
||||||
|
[[ -f "$BUILD_DIR/www/app-nginx.conf.sigil" ]] && mv $BUILD_DIR/www/app-nginx.conf.sigil $BUILD_DIR
|
||||||
[[ -f "$BUILD_DIR/www/mime.types" ]] && mv $BUILD_DIR/www/mime.types $BUILD_DIR
|
[[ -f "$BUILD_DIR/www/mime.types" ]] && mv $BUILD_DIR/www/mime.types $BUILD_DIR
|
||||||
[[ -f "$BUILD_DIR/www/CHECKS" ]] && mv $BUILD_DIR/www/CHECKS $BUILD_DIR
|
[[ -f "$BUILD_DIR/www/CHECKS" ]] && mv $BUILD_DIR/www/CHECKS $BUILD_DIR
|
||||||
[[ -f "$BUILD_DIR/www/app.json" ]] && mv $BUILD_DIR/www/app.json $BUILD_DIR
|
[[ -f "$BUILD_DIR/www/app.json" ]] && mv $BUILD_DIR/www/app.json $BUILD_DIR
|
||||||
@ -130,16 +131,20 @@ EOF
|
|||||||
|
|
||||||
cd $CUR_DIR
|
cd $CUR_DIR
|
||||||
|
|
||||||
|
# Add support for app-nginx.conf.sigil
|
||||||
|
if [ -f $BUILD_DIR/app-nginx.conf.sigil ] ; then
|
||||||
|
echo "-----> using user provided app-nginx.conf.sigil"
|
||||||
|
cp $BUILD_DIR/app-nginx.conf.sigil $BUILD_DIR/nginx/nginx.conf.sigil
|
||||||
|
|
||||||
# Test for user override on nginx config...
|
# Allow deprecated nginx.conf.erb
|
||||||
if [ -f $BUILD_DIR/nginx.conf.erb ] ; then
|
if [ -f $BUILD_DIR/nginx.conf.erb ] ; then
|
||||||
echo "-----> using user provided nginx.conf.erb"
|
echo "-----> DEPRECATED: using user provided nginx.conf.erb"
|
||||||
cp $BUILD_DIR/nginx.conf.erb $BUILD_DIR/nginx/nginx.conf.erb
|
cp $BUILD_DIR/nginx.conf.erb $BUILD_DIR/nginx/nginx.conf.erb
|
||||||
|
|
||||||
# ...else, force default file
|
# ...else, force default file
|
||||||
else
|
else
|
||||||
echo "-----> using default nginx.conf.erb"
|
echo "-----> using default nginx.conf.sigil"
|
||||||
cp conf/nginx.conf.erb $BUILD_DIR/nginx/nginx.conf.erb
|
cp conf/nginx.conf.sigil $BUILD_DIR/nginx/nginx.conf.sigil
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# build mime.types unless overridden by user
|
# build mime.types unless overridden by user
|
||||||
@ -152,12 +157,15 @@ else
|
|||||||
cp conf/mime.types $BUILD_DIR/nginx/mime.types
|
cp conf/mime.types $BUILD_DIR/nginx/mime.types
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# build a startup script
|
# build a startup script
|
||||||
cat <<EOF >"$BUILD_DIR/start_nginx"
|
cat <<EOF >"$BUILD_DIR/start_nginx"
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
rm -f /app/nginx/nginx.conf
|
rm -f /app/nginx/nginx.conf
|
||||||
erb /app/nginx/nginx.conf.erb > /app/nginx/nginx.conf
|
if [[ -f /app/nginx/nginx.conf.sigil ]]; then
|
||||||
|
/app/sigil/sigil -f /app/nginx/nginx.conf.sigil NGINX_ROOT="\$NGINX_ROOT" PORT="\$PORT" | cat -s > /app/nginx/nginx.conf
|
||||||
|
else
|
||||||
|
erb /app/nginx/nginx.conf.erb > /app/nginx/nginx.conf
|
||||||
|
fi
|
||||||
exec /app/nginx/nginx -p /app/nginx -c /app/nginx/nginx.conf
|
exec /app/nginx/nginx -p /app/nginx -c /app/nginx/nginx.conf
|
||||||
EOF
|
EOF
|
||||||
chmod +x "$BUILD_DIR/start_nginx"
|
chmod +x "$BUILD_DIR/start_nginx"
|
||||||
|
@ -11,13 +11,13 @@ http {
|
|||||||
types_hash_max_size 2048;
|
types_hash_max_size 2048;
|
||||||
include mime.types;
|
include mime.types;
|
||||||
server {
|
server {
|
||||||
listen <%= ENV["PORT"] %>;
|
listen {{ $.PORT }};
|
||||||
server_name _;
|
server_name _;
|
||||||
<% if ENV["NGINX_ROOT"] %>
|
{{ if ne $.NGINX_ROOT "" }}
|
||||||
root /app/www/<%= ENV["NGINX_ROOT"] %>;
|
root /app/www/{{ $.NGINX_ROOT }};
|
||||||
<% else %>
|
{{ else }}
|
||||||
root /app/www;
|
root /app/www;
|
||||||
<% end %>
|
{{ end }}
|
||||||
index index.html;
|
index index.html;
|
||||||
|
|
||||||
location / {
|
location / {
|
Loading…
Reference in New Issue
Block a user