Compare commits
1 Commits
a0f91d4fa9
...
4631514798
Author | SHA1 | Date | |
---|---|---|---|
|
4631514798 |
@ -2,7 +2,7 @@ name: Create Docker Image
|
|||||||
run-name: ${{ gitea.actor }} Building Docker Image 🐳
|
run-name: ${{ gitea.actor }} Building Docker Image 🐳
|
||||||
on: [push]
|
on: [push]
|
||||||
env:
|
env:
|
||||||
VERSION: 8.4-mysql
|
VERSION: 8.3-fpm-mysql
|
||||||
DOCKER_HOST: tcp://127.0.0.1:2375
|
DOCKER_HOST: tcp://127.0.0.1:2375
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
# NAME docker/php
|
# NAME docker/php
|
||||||
# VERSION 8.4-mysql
|
# VERSION 8.3-fpm-alpine
|
||||||
|
|
||||||
FROM gitea.dege.au/docker/php:8.4
|
FROM gitea.dege.au/docker/php:8.3-fpm
|
||||||
|
|
||||||
USER root
|
RUN apk add --no-cache mysql-client && \
|
||||||
RUN install-php-extensions pdo_mysql mysqli \
|
docker-php-ext-install -j$(nproc) pdo_mysql mysqli
|
||||||
&& apk add --no-cache npm mysql-client
|
|
||||||
USER ${SITE_USER}
|
RUN apk add --no-cache npm mysql-client
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
# NAME docker/php
|
# NAME docker/php
|
||||||
# VERSION 8.4-mysql-test
|
# VERSION 8.3-fpm-mysql-test
|
||||||
|
|
||||||
FROM gitea.dege.au/docker/php:8.4-mysql
|
FROM gitea.dege.au/docker/php:8.3-fpm-mysql
|
||||||
|
|
||||||
# Add xdebug
|
# Add xdebug
|
||||||
USER root
|
RUN apk --no-cache add linux-headers \
|
||||||
RUN install-php-extensions xdebug
|
&& pecl_install xdebug \
|
||||||
USER ${SITE_USER}
|
&& apk --no-cache del linux-headers
|
||||||
|
182
docker/init
Executable file
182
docker/init
Executable file
@ -0,0 +1,182 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
role=${CONTAINER_ROLE:-app}
|
||||||
|
env=${APP_ENV:-production}
|
||||||
|
php=${PHP_DIR:-/var/www/html}
|
||||||
|
composer=${COMPOSER_HOME:-/var/cache/composer}
|
||||||
|
|
||||||
|
SITE_USER=${SITE_USER:-www-data}
|
||||||
|
NGINX_START=${NGINX_START:-TRUE}
|
||||||
|
MEMCACHED_START=${MEMCACHED_START:-FALSE}
|
||||||
|
|
||||||
|
# To run a local queue, running jobs from the queue "hostname"
|
||||||
|
LOCAL_QUEUE=${LOCAL_QUEUE:-FALSE}
|
||||||
|
# Optional additional queues to run for
|
||||||
|
#LOCAL_QUEUES=
|
||||||
|
|
||||||
|
function mp() {
|
||||||
|
set +e
|
||||||
|
mountpoint -q $1
|
||||||
|
local mp=$?
|
||||||
|
set -e
|
||||||
|
echo ${mp}
|
||||||
|
}
|
||||||
|
|
||||||
|
function nginx_start() {
|
||||||
|
# Start NGINX
|
||||||
|
if [ -x /usr/sbin/nginx -a "${NGINX_START}" == "TRUE" ]; then
|
||||||
|
echo "* Starting NGINX..."
|
||||||
|
/usr/sbin/nginx -g 'daemon on; master_process on;'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function wait_for_db() {
|
||||||
|
# Wait for DB to be active
|
||||||
|
if [ -n "${DB_HOST}" -a -n "${DB_PORT}" ]; then
|
||||||
|
while ! wait-for-it -h ${DB_HOST} -p ${DB_PORT} -t 5 -q; do
|
||||||
|
echo "? Waiting for database at ${DB_HOST}:${DB_PORT}"
|
||||||
|
sleep 1;
|
||||||
|
done
|
||||||
|
echo "- DB is active on ${DB_HOST}:${DB_PORT}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run any container setup
|
||||||
|
[ -x /sbin/init-container ] && /sbin/init-container
|
||||||
|
|
||||||
|
# General Setup
|
||||||
|
if [ -x /usr/bin/memcached -a "${MEMCACHED_START}" == "TRUE" ]; then
|
||||||
|
echo "* Starting MEMCACHED..."
|
||||||
|
/usr/bin/memcached -d -P /run/memcached/memcached.pid -u memcached
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Laravel Specific
|
||||||
|
if [ -r artisan -a -e ${php}/.env ]; then
|
||||||
|
mp=$(mp ${php})
|
||||||
|
|
||||||
|
# Only adjust perms if this is an external mountpoint
|
||||||
|
if [ ${mp} -eq 0 -o -n "${FORCE_PERMS}" ] ; then
|
||||||
|
if [ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ]; then
|
||||||
|
echo "* Setting Permissions..."
|
||||||
|
# Make sure our permissions are appropraite
|
||||||
|
find ${php} -type f -exec chmod 640 {} \;
|
||||||
|
find ${php} -type d -exec chmod 750 {} \;
|
||||||
|
find ${php}/public -type f -exec chmod 644 {} \;
|
||||||
|
find ${php}/public -type d -exec chmod 755 {} \;
|
||||||
|
chmod o+rx ${php}
|
||||||
|
chmod a+rx ${php}/artisan
|
||||||
|
chown -R ${SITE_USER}:www-data ${php}
|
||||||
|
chown -R www-data:www-data ${php}/storage ${php}/bootstrap ${php}/composer.*
|
||||||
|
[ -e ${php}/vendor ] && chown -R www-data:www-data ${php}/vendor
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# See if we need to refresh our dependancies
|
||||||
|
if [[ -r composer.json && ( -e .composer.refresh || ! -d vendor ) ]]; then
|
||||||
|
echo "* Composer installing dependancies..."
|
||||||
|
|
||||||
|
rm -f ${php}/bootstrap/cache/*.php
|
||||||
|
if [ "${env}" != "local" ]; then
|
||||||
|
NODEV="--no-dev"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mp=$(mp ${composer})
|
||||||
|
|
||||||
|
if [ ${mp} -eq 0 -o -n "${FORCE_PERMS}" ] ; then
|
||||||
|
[ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && chown -R www-data:www-data ${composer}
|
||||||
|
[ ! -d ${php}/vendor ] && mkdir -m 750 ${php}/vendor && chown www-data:www-data ${php}/vendor
|
||||||
|
[ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && chmod g+w ${php}
|
||||||
|
fi
|
||||||
|
|
||||||
|
su www-data -s /bin/sh -c "composer install --optimize-autoloader ${NODEV}" && ( test -e .composer.refresh && rm -f .composer.refresh )
|
||||||
|
[ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && [ ${mp} -eq 0 ] && chmod g-w ${php}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e .lumen ]; then
|
||||||
|
echo "* Lumen detected, not caching configuration..."
|
||||||
|
else
|
||||||
|
# We only check for non mount points, in case this container has the app inside
|
||||||
|
mp=$(mp ${php})
|
||||||
|
if [ ${mp} -eq 1 ]; then
|
||||||
|
echo "* Caching configuration..."
|
||||||
|
su www-data -s /bin/sh -c "(php artisan optimize)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${role}" = "app" ]; then
|
||||||
|
if [ "${env}" != "local" ]; then
|
||||||
|
if [ -z "${IGNORE_MIGRATION}" ]; then
|
||||||
|
if [ -r .migrate ]; then
|
||||||
|
echo "* Running migration..."
|
||||||
|
# If DB_HOST not set, source the env file
|
||||||
|
[ -z "${DB_HOST}" -a -r .env ] && . .env
|
||||||
|
|
||||||
|
wait_for_db
|
||||||
|
|
||||||
|
su www-data -s /bin/sh -c "php artisan migrate" && rm -f .migrate
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
[ -r .migrate ] && echo "! NOTE: Migration ignored due to IGNORE_MIGRATION"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If passport is installed
|
||||||
|
if [ -d ${php}/vendor/laravel/passport ]; then
|
||||||
|
echo "* Generating OAUTH keys ..."
|
||||||
|
set +e
|
||||||
|
su www-data -s /bin/sh -c "php artisan passport:keys"
|
||||||
|
set -e
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
nginx_start
|
||||||
|
|
||||||
|
if [ "${LOCAL_QUEUE}" = "TRUE" ]; then
|
||||||
|
echo "* Starting local queue for [$(hostname)${LOCAL_QUEUES:+,${LOCAL_QUEUES}}] with job timeout of [${WORK_TIMEOUT:-90}], trying [${WORK_TRIES:-1}] times..."
|
||||||
|
su www-data -s /bin/sh -c "
|
||||||
|
(while true; do php ${PHP_OPTIONS} artisan queue:work --verbose --tries=${WORK_TRIES:-1} --timeout=${WORK_TIMEOUT:-90} --queue=$(hostname)${LOCAL_QUEUES:+,${LOCAL_QUEUES}} ${WORK_MEMORY:+--memory=${WORK_MEMORY}} ${WORK_ONCE:+--once}; done) &
|
||||||
|
"
|
||||||
|
fi
|
||||||
|
|
||||||
|
set +e
|
||||||
|
[ -x init-php.sh ] && su www-data -s /bin/bash "init-php.sh" &
|
||||||
|
|
||||||
|
exec /usr/local/bin/docker-php-entrypoint "$@"
|
||||||
|
|
||||||
|
elif [ "$role" = "queue" ]; then
|
||||||
|
QUEUE_CMD=work
|
||||||
|
|
||||||
|
if [ "${env}" == "local" ]; then
|
||||||
|
QUEUE_CMD=listen
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "* Running the queue..."
|
||||||
|
# We'll delay starting in case the app is caching
|
||||||
|
sleep 15
|
||||||
|
|
||||||
|
wait_for_db
|
||||||
|
|
||||||
|
su www-data -s /bin/sh -c "
|
||||||
|
while true; do
|
||||||
|
php ${PHP_OPTIONS} artisan queue:${QUEUE_CMD} --verbose --tries=${WORK_TRIES:-1} --timeout=${WORK_TIMEOUT:-90} ${WORK_QUEUES:+--queue=${WORK_QUEUES}} ${WORK_MEMORY:+--memory=${WORK_MEMORY}} ${WORK_ONCE:+--once}
|
||||||
|
done
|
||||||
|
"
|
||||||
|
|
||||||
|
elif [ "$role" = "scheduler" ]; then
|
||||||
|
echo "* Running the scheduler..."
|
||||||
|
# We'll delay starting in case the app is caching
|
||||||
|
sleep 15
|
||||||
|
|
||||||
|
su www-data -s /bin/sh -c "
|
||||||
|
while true; do
|
||||||
|
php ${PHP_OPTIONS} artisan schedule:work --verbose --no-interaction
|
||||||
|
done
|
||||||
|
"
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
nginx_start
|
||||||
|
|
||||||
|
echo "? NO container role \"${role}\", AND/OR no laravel install, just starting php-fpm"
|
||||||
|
exec /usr/local/bin/docker-php-entrypoint "$@"
|
||||||
|
fi
|
@ -1,175 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
role=${CONTAINER_ROLE:-app}
|
|
||||||
env=${APP_ENV:-production}
|
|
||||||
php=${PHP_DIR:-/app}
|
|
||||||
composer=${COMPOSER_HOME:-/var/cache/composer}
|
|
||||||
|
|
||||||
SITE_USER=${SITE_USER:-www-data}
|
|
||||||
MEMCACHED_START=${MEMCACHED_START:-FALSE}
|
|
||||||
RUN_USER=$(id -u)
|
|
||||||
[ "${RUN_USER}" = "0" ] && USE_SU=1
|
|
||||||
|
|
||||||
# To run a local queue, running jobs from the queue "hostname"
|
|
||||||
LOCAL_QUEUE=${LOCAL_QUEUE:-FALSE}
|
|
||||||
# Optional additional queues to run for
|
|
||||||
#LOCAL_QUEUES=
|
|
||||||
|
|
||||||
function mp() {
|
|
||||||
set +e
|
|
||||||
mountpoint -q $1
|
|
||||||
local mp=$?
|
|
||||||
set -e
|
|
||||||
echo ${mp}
|
|
||||||
}
|
|
||||||
|
|
||||||
function wait_for_db() {
|
|
||||||
# Wait for DB to be active
|
|
||||||
if [ -n "${DB_HOST}" -a -n "${DB_PORT}" ]; then
|
|
||||||
while ! wait-for-it -h ${DB_HOST} -p ${DB_PORT} -t 5 -q; do
|
|
||||||
echo "? Waiting for database at ${DB_HOST}:${DB_PORT}"
|
|
||||||
sleep 1;
|
|
||||||
done
|
|
||||||
echo "- DB is active on ${DB_HOST}:${DB_PORT}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "* Started with [$@]"
|
|
||||||
|
|
||||||
# Run any container setup
|
|
||||||
[ -x /sbin/init-container ] && /sbin/init-container
|
|
||||||
|
|
||||||
# General Setup
|
|
||||||
if [ -x /usr/bin/memcached -a "${MEMCACHED_START}" == "TRUE" ]; then
|
|
||||||
echo "* Starting MEMCACHED..."
|
|
||||||
/usr/bin/memcached -d -P /run/memcached/memcached.pid -u memcached
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Laravel Specific
|
|
||||||
if [ -r artisan -a -e ${php}/.env ]; then
|
|
||||||
echo "* Laravel Setup..."
|
|
||||||
mp=$(mp ${php})
|
|
||||||
echo " - ${php} is an external mount point ${mp}"
|
|
||||||
|
|
||||||
# Only adjust perms if this is an external mountpoint
|
|
||||||
if [ -n "${BUILD}" -o -n "${FORCE_PERMS}" -o ${mp} -eq 0 ]; then
|
|
||||||
if [ -n "${BUILD}" -o -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ]; then
|
|
||||||
echo " - Setting Permissions..."
|
|
||||||
# Make sure our permissions are appropraite
|
|
||||||
find ${php} -type f -exec chmod 640 {} \;
|
|
||||||
find ${php} -type d -exec chmod 750 {} \;
|
|
||||||
find ${php}/public -type f -exec chmod 644 {} \;
|
|
||||||
find ${php}/public -type d -exec chmod 755 {} \;
|
|
||||||
chmod o+rx ${php}
|
|
||||||
chmod a+rx ${php}/artisan
|
|
||||||
chown -R ${SITE_USER}:www-data ${php}
|
|
||||||
chown -R ${SITE_USER}:www-data ${php}/storage ${php}/bootstrap ${php}/composer.*
|
|
||||||
[ -e ${php}/vendor ] && chown -R ${SITE_USER}:www-data ${php}/vendor
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# See if we need to refresh our dependancies (only need if web dir is externally mounted)
|
|
||||||
if [[ -r composer.json && ( -e .composer.refresh || ! -d vendor ) ]]; then
|
|
||||||
echo " - Composer installing dependancies..."
|
|
||||||
|
|
||||||
rm -f ${php}/bootstrap/cache/*.php
|
|
||||||
if [ "${env}" != "local" ]; then
|
|
||||||
NODEV="--no-dev"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mp=$(mp ${composer})
|
|
||||||
echo " - [${composer}] is a mount point [${mp}]"
|
|
||||||
|
|
||||||
if [ -n "${BUILD}" -o -n "${FORCE_PERMS}" -o ${mp} -eq 0 ]; then
|
|
||||||
[ -n "${BUILD}" -o -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && chown -R ${SITE_USER}:www-data ${composer}
|
|
||||||
[ ! -d ${php}/vendor ] && mkdir -m 750 ${php}/vendor && chown ${SITE_USER}:www-data ${php}/vendor
|
|
||||||
[ -n "${BUILD}" -o -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && chmod g+w ${php}
|
|
||||||
fi
|
|
||||||
|
|
||||||
CMD="composer install --optimize-autoloader ${NODEV}"
|
|
||||||
(( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD}) && ( test -e .composer.refresh && rm -f .composer.refresh )
|
|
||||||
[ -n "${BUILD}" -o -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && [ ${mp} -eq 0 ] && chmod g-w ${php}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Generate our Encryption Key
|
|
||||||
[ -z "${BUILD}" ] && [ -z "${APP_KEY}" ] \
|
|
||||||
&& grep -qe '^APP_KEY=$' .env \
|
|
||||||
&& echo ' + Encryption Key auto created, replace with with "artisan key:generate --force"' \
|
|
||||||
&& ./artisan key:generate
|
|
||||||
|
|
||||||
# We only check for non mount points, in case this container has the app inside
|
|
||||||
mp=$(mp ${php})
|
|
||||||
if [ -n "${BUILD}" -o ${mp} -eq 0 ]; then
|
|
||||||
echo " - Caching configuration..."
|
|
||||||
CMD="php artisan optimize"
|
|
||||||
( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${role}" = "app" ]; then
|
|
||||||
if [ "${env}" != "local" ]; then
|
|
||||||
if [ -z "${IGNORE_MIGRATION}" ]; then
|
|
||||||
if [ -r .migrate ]; then
|
|
||||||
echo " - Running migration..."
|
|
||||||
# If DB_HOST not set, source the env file
|
|
||||||
[ -z "${DB_HOST}" -a -r .env ] && . .env
|
|
||||||
|
|
||||||
wait_for_db
|
|
||||||
|
|
||||||
CMD="php artisan migrate"
|
|
||||||
(( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD}) && rm -f .migrate
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
[ -r .migrate ] && echo "! NOTE: Migration ignored due to IGNORE_MIGRATION"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If passport is installed
|
|
||||||
if [ -d ${php}/vendor/laravel/passport ]; then
|
|
||||||
echo " - Generating OAUTH keys ..."
|
|
||||||
set +e
|
|
||||||
CMD="php artisan passport:keys"
|
|
||||||
( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD}
|
|
||||||
set -e
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${LOCAL_QUEUE}" = "TRUE" ]; then
|
|
||||||
echo " - Starting local queue for [$(hostname)${LOCAL_QUEUES:+,${LOCAL_QUEUES}}] with job timeout of [${WORK_TIMEOUT:-90}], trying [${WORK_TRIES:-1}] times..."
|
|
||||||
CMD="(while true; do php ${PHP_OPTIONS} artisan queue:work --verbose --tries=${WORK_TRIES:-1} --timeout=${WORK_TIMEOUT:-90} --queue=$(hostname)${LOCAL_QUEUES:+,${LOCAL_QUEUES}} ${WORK_MEMORY:+--memory=${WORK_MEMORY}} ${WORK_ONCE:+--once}; done) &"
|
|
||||||
( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD}
|
|
||||||
fi
|
|
||||||
|
|
||||||
set +e
|
|
||||||
[ -x init-php.sh ] && (( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "init-php.sh &" ) || init-php.sh &)
|
|
||||||
|
|
||||||
exec /usr/local/bin/docker-php-entrypoint "$@"
|
|
||||||
|
|
||||||
elif [ "$role" = "queue" ]; then
|
|
||||||
QUEUE_CMD=work
|
|
||||||
|
|
||||||
if [ "${env}" == "local" ]; then
|
|
||||||
QUEUE_CMD=listen
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo " - Running the queue..."
|
|
||||||
# We'll delay starting in case the app is caching
|
|
||||||
sleep 15
|
|
||||||
|
|
||||||
wait_for_db
|
|
||||||
|
|
||||||
CMD="while true; do php ${PHP_OPTIONS} artisan queue:${QUEUE_CMD} --verbose --tries=${WORK_TRIES:-1} --timeout=${WORK_TIMEOUT:-90} ${WORK_QUEUES:+--queue=${WORK_QUEUES}} ${WORK_MEMORY:+--memory=${WORK_MEMORY}} ${WORK_ONCE:+--once}; done"
|
|
||||||
( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD}
|
|
||||||
|
|
||||||
elif [ "$role" = "scheduler" ]; then
|
|
||||||
echo " - Running the scheduler..."
|
|
||||||
# We'll delay starting in case the app is caching
|
|
||||||
sleep 15
|
|
||||||
|
|
||||||
CMD="while true; do php ${PHP_OPTIONS} artisan schedule:work --verbose --no-interaction; done"
|
|
||||||
( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD}
|
|
||||||
fi
|
|
||||||
|
|
||||||
else
|
|
||||||
echo "? NO container role \"${role}\", AND/OR no laravel install, just starting php-fpm"
|
|
||||||
exec /usr/local/bin/docker-php-entrypoint "$@"
|
|
||||||
fi
|
|
43
docker/nginx-app.conf
Normal file
43
docker/nginx-app.conf
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
listen [::]:80 default_server;
|
||||||
|
|
||||||
|
access_log off;
|
||||||
|
client_max_body_size 64m;
|
||||||
|
error_log /dev/stdout info;
|
||||||
|
fastcgi_buffering off;
|
||||||
|
fastcgi_request_buffering off;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_min_length 10240;
|
||||||
|
gzip_proxied expired no-cache no-store private auth;
|
||||||
|
gzip_types text/plain text/css application/javascript;
|
||||||
|
index index.php index.html;
|
||||||
|
root /var/www/html/public;
|
||||||
|
server_tokens off;
|
||||||
|
|
||||||
|
set $my_https "off";
|
||||||
|
if ($http_x_forwarded_proto = "https") {
|
||||||
|
set $my_https "on";
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
try_files $uri =404;
|
||||||
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||||
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
|
||||||
|
include fastcgi_params;
|
||||||
|
|
||||||
|
fastcgi_param HTTPS $my_https;
|
||||||
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_param SERVER_NAME $host;
|
||||||
|
|
||||||
|
fastcgi_read_timeout 600s;
|
||||||
|
fastcgi_send_timeout 600s;
|
||||||
|
}
|
||||||
|
}
|
16
docker/pecl_install
Executable file
16
docker/pecl_install
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This will install our PHP modules
|
||||||
|
# call peck-install module1 module2
|
||||||
|
|
||||||
|
# First install some dependancies
|
||||||
|
apk add --no-cache autoconf gcc libc-dev make
|
||||||
|
|
||||||
|
# Install the modules
|
||||||
|
for module in $@; do
|
||||||
|
pecl install -o -f ${module} && docker-php-ext-enable ${module}
|
||||||
|
done
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf /tmp/pear
|
||||||
|
apk del --no-cache autoconf gcc libc-dev make
|
12
docker/www.conf
Normal file
12
docker/www.conf
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[www]
|
||||||
|
group = www-data
|
||||||
|
listen = 127.0.0.1:9000
|
||||||
|
pm = dynamic
|
||||||
|
pm.max_children = 25
|
||||||
|
pm.max_spare_servers = 10
|
||||||
|
pm.min_spare_servers = 5
|
||||||
|
pm.start_servers = 10
|
||||||
|
user = www-data
|
||||||
|
prefix = /var/www/html
|
||||||
|
php_admin_value[memory_limit] = 512M
|
||||||
|
php_admin_value[max_execution_time] = 300
|
182
wait-for-it
182
wait-for-it
@ -1,182 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# Use this script to test if a given TCP host/port are available
|
|
||||||
|
|
||||||
WAITFORIT_cmdname=${0##*/}
|
|
||||||
|
|
||||||
echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
|
|
||||||
|
|
||||||
usage()
|
|
||||||
{
|
|
||||||
cat << USAGE >&2
|
|
||||||
Usage:
|
|
||||||
$WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args]
|
|
||||||
-h HOST | --host=HOST Host or IP under test
|
|
||||||
-p PORT | --port=PORT TCP port under test
|
|
||||||
Alternatively, you specify the host and port as host:port
|
|
||||||
-s | --strict Only execute subcommand if the test succeeds
|
|
||||||
-q | --quiet Don't output any status messages
|
|
||||||
-t TIMEOUT | --timeout=TIMEOUT
|
|
||||||
Timeout in seconds, zero for no timeout
|
|
||||||
-- COMMAND ARGS Execute command with args after the test finishes
|
|
||||||
USAGE
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
wait_for()
|
|
||||||
{
|
|
||||||
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
|
|
||||||
echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
|
|
||||||
else
|
|
||||||
echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout"
|
|
||||||
fi
|
|
||||||
WAITFORIT_start_ts=$(date +%s)
|
|
||||||
while :
|
|
||||||
do
|
|
||||||
if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then
|
|
||||||
nc -z $WAITFORIT_HOST $WAITFORIT_PORT
|
|
||||||
WAITFORIT_result=$?
|
|
||||||
else
|
|
||||||
(echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
|
|
||||||
WAITFORIT_result=$?
|
|
||||||
fi
|
|
||||||
if [[ $WAITFORIT_result -eq 0 ]]; then
|
|
||||||
WAITFORIT_end_ts=$(date +%s)
|
|
||||||
echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
return $WAITFORIT_result
|
|
||||||
}
|
|
||||||
|
|
||||||
wait_for_wrapper()
|
|
||||||
{
|
|
||||||
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
|
|
||||||
if [[ $WAITFORIT_QUIET -eq 1 ]]; then
|
|
||||||
timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
|
|
||||||
else
|
|
||||||
timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
|
|
||||||
fi
|
|
||||||
WAITFORIT_PID=$!
|
|
||||||
trap "kill -INT -$WAITFORIT_PID" INT
|
|
||||||
wait $WAITFORIT_PID
|
|
||||||
WAITFORIT_RESULT=$?
|
|
||||||
if [[ $WAITFORIT_RESULT -ne 0 ]]; then
|
|
||||||
echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
|
|
||||||
fi
|
|
||||||
return $WAITFORIT_RESULT
|
|
||||||
}
|
|
||||||
|
|
||||||
# process arguments
|
|
||||||
while [[ $# -gt 0 ]]
|
|
||||||
do
|
|
||||||
case "$1" in
|
|
||||||
*:* )
|
|
||||||
WAITFORIT_hostport=(${1//:/ })
|
|
||||||
WAITFORIT_HOST=${WAITFORIT_hostport[0]}
|
|
||||||
WAITFORIT_PORT=${WAITFORIT_hostport[1]}
|
|
||||||
shift 1
|
|
||||||
;;
|
|
||||||
--child)
|
|
||||||
WAITFORIT_CHILD=1
|
|
||||||
shift 1
|
|
||||||
;;
|
|
||||||
-q | --quiet)
|
|
||||||
WAITFORIT_QUIET=1
|
|
||||||
shift 1
|
|
||||||
;;
|
|
||||||
-s | --strict)
|
|
||||||
WAITFORIT_STRICT=1
|
|
||||||
shift 1
|
|
||||||
;;
|
|
||||||
-h)
|
|
||||||
WAITFORIT_HOST="$2"
|
|
||||||
if [[ $WAITFORIT_HOST == "" ]]; then break; fi
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
--host=*)
|
|
||||||
WAITFORIT_HOST="${1#*=}"
|
|
||||||
shift 1
|
|
||||||
;;
|
|
||||||
-p)
|
|
||||||
WAITFORIT_PORT="$2"
|
|
||||||
if [[ $WAITFORIT_PORT == "" ]]; then break; fi
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
--port=*)
|
|
||||||
WAITFORIT_PORT="${1#*=}"
|
|
||||||
shift 1
|
|
||||||
;;
|
|
||||||
-t)
|
|
||||||
WAITFORIT_TIMEOUT="$2"
|
|
||||||
if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
--timeout=*)
|
|
||||||
WAITFORIT_TIMEOUT="${1#*=}"
|
|
||||||
shift 1
|
|
||||||
;;
|
|
||||||
--)
|
|
||||||
shift
|
|
||||||
WAITFORIT_CLI=("$@")
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
--help)
|
|
||||||
usage
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echoerr "Unknown argument: $1"
|
|
||||||
usage
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then
|
|
||||||
echoerr "Error: you need to provide a host and port to test."
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
|
|
||||||
WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15}
|
|
||||||
WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
|
|
||||||
WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
|
|
||||||
WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}
|
|
||||||
|
|
||||||
# Check to see if timeout is from busybox?
|
|
||||||
WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
|
|
||||||
WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
|
|
||||||
|
|
||||||
WAITFORIT_BUSYTIMEFLAG=""
|
|
||||||
if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
|
|
||||||
WAITFORIT_ISBUSY=1
|
|
||||||
# Check if busybox timeout uses -t flag
|
|
||||||
# (recent Alpine versions don't support -t anymore)
|
|
||||||
if timeout &>/dev/stdout | grep -q -e '-t '; then
|
|
||||||
WAITFORIT_BUSYTIMEFLAG="-t"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
WAITFORIT_ISBUSY=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $WAITFORIT_CHILD -gt 0 ]]; then
|
|
||||||
wait_for
|
|
||||||
WAITFORIT_RESULT=$?
|
|
||||||
exit $WAITFORIT_RESULT
|
|
||||||
else
|
|
||||||
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
|
|
||||||
wait_for_wrapper
|
|
||||||
WAITFORIT_RESULT=$?
|
|
||||||
else
|
|
||||||
wait_for
|
|
||||||
WAITFORIT_RESULT=$?
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $WAITFORIT_CLI != "" ]]; then
|
|
||||||
if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then
|
|
||||||
echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess"
|
|
||||||
exit $WAITFORIT_RESULT
|
|
||||||
fi
|
|
||||||
exec "${WAITFORIT_CLI[@]}"
|
|
||||||
else
|
|
||||||
exit $WAITFORIT_RESULT
|
|
||||||
fi
|
|
Loading…
x
Reference in New Issue
Block a user