Merge pull request #53 from jackmcpickle/webroot_script_cleanups
Webroot script cleanups
This commit is contained in:
@@ -2,7 +2,7 @@ FROM alpine:3.4
|
|||||||
|
|
||||||
MAINTAINER ngineered <support@ngineered.co.uk>
|
MAINTAINER ngineered <support@ngineered.co.uk>
|
||||||
|
|
||||||
ENV php_conf /etc/php5/php.ini
|
ENV php_conf /etc/php5/php.ini
|
||||||
ENV fpm_conf /etc/php5/php-fpm.conf
|
ENV fpm_conf /etc/php5/php-fpm.conf
|
||||||
ENV composer_hash e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae
|
ENV composer_hash e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae
|
||||||
|
|
||||||
@@ -77,6 +77,7 @@ sed -i -e "s/;listen.mode = 0660/listen.mode = 0666/g" ${fpm_conf} && \
|
|||||||
sed -i -e "s/;listen.owner = nobody/listen.owner = nginx/g" ${fpm_conf} && \
|
sed -i -e "s/;listen.owner = nobody/listen.owner = nginx/g" ${fpm_conf} && \
|
||||||
sed -i -e "s/;listen.group = nobody/listen.group = nginx/g" ${fpm_conf} && \
|
sed -i -e "s/;listen.group = nobody/listen.group = nginx/g" ${fpm_conf} && \
|
||||||
sed -i -e "s/listen = 127.0.0.1:9000/listen = \/var\/run\/php-fpm.sock/g" ${fpm_conf} &&\
|
sed -i -e "s/listen = 127.0.0.1:9000/listen = \/var\/run\/php-fpm.sock/g" ${fpm_conf} &&\
|
||||||
|
sed -i -e "s/^;clear_env = no$/clear_env = no/" ${fpm_conf} &&\
|
||||||
ln -s /etc/php5/php.ini /etc/php5/conf.d/php.ini && \
|
ln -s /etc/php5/php.ini /etc/php5/conf.d/php.ini && \
|
||||||
find /etc/php5/conf.d/ -name "*.ini" -exec sed -i -re 's/^(\s*)#(.*)/\1;\2/g' {} \;
|
find /etc/php5/conf.d/ -name "*.ini" -exec sed -i -re 's/^(\s*)#(.*)/\1;\2/g' {} \;
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ fi
|
|||||||
|
|
||||||
# Set custom webroot
|
# Set custom webroot
|
||||||
if [ ! -z "$WEBROOT" ]; then
|
if [ ! -z "$WEBROOT" ]; then
|
||||||
sed -i "s#root /var/www/html;#root ${WEBROOT};#g" /etc/nginx/sites-available/default.conf
|
webroot=$WEBROOT
|
||||||
|
sed -i "s#root /var/www/html;#root ${webroot};#g" /etc/nginx/sites-available/default.conf
|
||||||
|
else
|
||||||
|
webroot=/var/www/html
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Setup git variables
|
# Setup git variables
|
||||||
@@ -26,25 +29,24 @@ if [ ! -z "$GIT_NAME" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Dont pull code down if the .git folder exists
|
# Dont pull code down if the .git folder exists
|
||||||
if [ ! -d "/var/www/html/.git" ]; then
|
if [ ! -d "${webroot}/.git" ]; then
|
||||||
# Pull down code from git for our site!
|
# Pull down code from git for our site!
|
||||||
if [ ! -z "$GIT_REPO" ]; then
|
if [ ! -z "$GIT_REPO" ]; then
|
||||||
# Remove the test index file
|
# Remove the test index file
|
||||||
rm -Rf /var/www/html/index.php
|
rm -Rf /var/www/html/index.php
|
||||||
if [ ! -z "$GIT_BRANCH" ]; then
|
if [ ! -z "$GIT_BRANCH" ]; then
|
||||||
git clone -b $GIT_BRANCH $GIT_REPO /var/www/html/
|
git clone -b $GIT_BRANCH $GIT_REPO $webroot
|
||||||
else
|
else
|
||||||
git clone $GIT_REPO /var/www/html/
|
git clone $GIT_REPO $webroot
|
||||||
fi
|
fi
|
||||||
chown -Rf nginx.nginx /var/www/html
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Display PHP error's or not
|
# Display PHP error's or not
|
||||||
if [[ "$ERRORS" != "1" ]] ; then
|
if [[ "$ERRORS" != "1" ]] ; then
|
||||||
echo php_flag[display_errors] = off >> /etc/php5/php-fpm.conf
|
echo php_flag[display_errors] = off >> $fpm_conf
|
||||||
else
|
else
|
||||||
echo php_flag[display_errors] = on >> /etc/php5/php-fpm.conf
|
echo php_flag[display_errors] = on >> $fpm_conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Display Version Details or not
|
# Display Version Details or not
|
||||||
@@ -69,18 +71,8 @@ if [ ! -z "$PHP_UPLOAD_MAX_FILESIZE" ]; then
|
|||||||
sed -i "s/upload_max_filesize = 100M/upload_max_filesize= ${PHP_UPLOAD_MAX_FILESIZE}M/g" /etc/php5/conf.d/php.ini
|
sed -i "s/upload_max_filesize = 100M/upload_max_filesize= ${PHP_UPLOAD_MAX_FILESIZE}M/g" /etc/php5/conf.d/php.ini
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Very dirty hack to replace variables in code with ENVIRONMENT values
|
# Always chown webroot for better mounting
|
||||||
if [[ "$TEMPLATE_NGINX_HTML" == "1" ]] ; then
|
chown -Rf nginx.nginx $webroot
|
||||||
for i in $(env)
|
|
||||||
do
|
|
||||||
variable=$(echo "$i" | cut -d'=' -f1)
|
|
||||||
value=$(echo "$i" | cut -d'=' -f2)
|
|
||||||
if [[ "$variable" != '%s' ]] ; then
|
|
||||||
replace='\$\$_'${variable}'_\$\$'
|
|
||||||
find /var/www/html -type f -exec sed -i -e 's/'${replace}'/'${value}'/g' {} \;
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Start supervisord and services
|
# Start supervisord and services
|
||||||
/usr/bin/supervisord -n -c /etc/supervisord.conf
|
/usr/bin/supervisord -n -c /etc/supervisord.conf
|
||||||
|
|||||||
Reference in New Issue
Block a user