Compare commits

..

No commits in common. "be60c6a506c94bfd380850b538e1d544b81fe0d3" and "f47f9828a365f8758d6d5655da8f772f8bc19798" have entirely different histories.

2 changed files with 52 additions and 73 deletions

View File

@ -6,38 +6,32 @@ env:
DOCKER_HOST: tcp://127.0.0.1:2375 DOCKER_HOST: tcp://127.0.0.1:2375
jobs: jobs:
test: # test:
strategy: # strategy:
matrix: # matrix:
arch: # arch:
- x86_64 # - x86_64
# arm64 # # arm64
#
name: Test Application # name: Test Application
runs-on: docker-${{ matrix.arch }} # runs-on: docker-${{ matrix.arch }}
container: # container:
image: docker:dind # image: docker:dind
privileged: true # privileged: true
#
steps: # steps:
- name: Environment Setup # - name: Environment Setup
run: | # run: |
# If we have a proxy use it # # If we have a proxy use it
if [ -n "${HTTP_PROXY}" ]; then echo "HTTP PROXY [${HTTP_PROXY}]"; sed -i -e s'/https/http/' /etc/apk/repositories; fi # if [ -n "${HTTP_PROXY}" ]; then echo "HTTP PROXY [${HTTP_PROXY}]"; sed -i -e s'/https/http/' /etc/apk/repositories; fi
# Some pre-reqs # # Some pre-reqs
apk add git nodejs npm # apk add git nodejs npm
## Some debugging info # ## Some debugging info
# env|sort # # env|sort
#
- name: Code Checkout # - name: Code Checkout
uses: actions/checkout@v4 # uses: actions/checkout@v4
#
- name: Build Assets
run: |
# Build assets
npm i
npm run prod
# - name: Run Tests # - name: Run Tests
# run: | # run: |
# mv .env.testing .env # mv .env.testing .env
@ -49,32 +43,19 @@ jobs:
# php artisan key:generate # php artisan key:generate
# php artisan migrate # php artisan migrate
# php artisan db:seed # php artisan db:seed
# # Build assets
# npm i
# npm run prod
# # run laravel tests # # run laravel tests
# # XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text --colors=never # # XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text --colors=never
- name: Cache page assets
id: cache-page-assets
uses: actions/cache@v3
env:
cache-name: page-assets
with:
path: |
public/css/app.css
key:
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
build: build:
strategy: strategy:
matrix: matrix:
arch: arch:
- x86_64 - x86_64
- arm64 - arm64
needs: [test] # needs: [test]
name: Build Docker Image name: Build Docker Image
runs-on: docker-${{ matrix.arch }} runs-on: docker-${{ matrix.arch }}
@ -114,12 +95,11 @@ jobs:
- name: Code Checkout - name: Code Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- if: ${{ steps.cache-page-assets.outputs.cache-hit != 'true' }} - name: Build Assets
name: List the state of node modules
continue-on-error: true
run: | run: |
ls -al # Build assets
ls -al public/css/ npm i
npm run prod
- name: Record version and Delete Unnecessary files - name: Record version and Delete Unnecessary files
run: | run: |

View File

@ -6,12 +6,8 @@ env=${APP_ENV:-production}
php=${PHP_DIR:-/var/www/html} php=${PHP_DIR:-/var/www/html}
composer=${COMPOSER_HOME:-/var/cache/composer} composer=${COMPOSER_HOME:-/var/cache/composer}
RUN_USER=$(id -u -n)
SITE_USER=${SITE_USER:-www-data} SITE_USER=${SITE_USER:-www-data}
MEMCACHED_START=${MEMCACHED_START:-FALSE} MEMCACHED_START=${MEMCACHED_START:-FALSE}
[ "${RUN_USER}" = "deon" ] && USE_SU=1
(( [ -n "${USE_SU}" ] && echo su ${SITE_USER} -s /bin/sh -c command ${USE_SU} ) || echo comman ${USE_SU}) && echo extra command
exit 1
# To run a local queue, running jobs from the queue "hostname" # To run a local queue, running jobs from the queue "hostname"
LOCAL_QUEUE=${LOCAL_QUEUE:-FALSE} LOCAL_QUEUE=${LOCAL_QUEUE:-FALSE}
@ -91,8 +87,7 @@ if [ -r artisan -a -e ${php}/.env ]; then
[ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && chmod g+w ${php} [ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && chmod g+w ${php}
fi fi
CMD="composer install --optimize-autoloader ${NODEV}" su ${SITE_USER} -s /bin/sh -c "composer install --optimize-autoloader ${NODEV}" && ( test -e .composer.refresh && rm -f .composer.refresh )
(( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD}) && ( 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} [ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && [ ${mp} -eq 0 ] && chmod g-w ${php}
fi fi
@ -100,8 +95,7 @@ if [ -r artisan -a -e ${php}/.env ]; then
mp=$(mp ${php}) mp=$(mp ${php})
if [ ${mp} -eq 1 ]; then if [ ${mp} -eq 1 ]; then
echo " - Caching configuration..." echo " - Caching configuration..."
CMD="php artisan optimize" su ${SITE_USER} -s /bin/sh -c "(php artisan optimize)"
( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD}
fi fi
if [ "${role}" = "app" ]; then if [ "${role}" = "app" ]; then
@ -114,8 +108,7 @@ if [ -r artisan -a -e ${php}/.env ]; then
wait_for_db wait_for_db
CMD="php artisan migrate" su ${SITE_USER} -s /bin/sh -c "php artisan migrate" && rm -f .migrate
(( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD}) && rm -f .migrate
fi fi
else else
[ -r .migrate ] && echo "! NOTE: Migration ignored due to IGNORE_MIGRATION" [ -r .migrate ] && echo "! NOTE: Migration ignored due to IGNORE_MIGRATION"
@ -125,20 +118,20 @@ if [ -r artisan -a -e ${php}/.env ]; then
if [ -d ${php}/vendor/laravel/passport ]; then if [ -d ${php}/vendor/laravel/passport ]; then
echo " - Generating OAUTH keys ..." echo " - Generating OAUTH keys ..."
set +e set +e
CMD="php artisan passport:keys" su ${SITE_USER} -s /bin/sh -c "php artisan passport:keys"
( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD}
set -e set -e
fi fi
fi fi
if [ "${LOCAL_QUEUE}" = "TRUE" ]; then 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..." 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) &" su ${SITE_USER} -s /bin/sh -c "
( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${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) &
"
fi fi
set +e set +e
[ -x init-php.sh ] && (( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "init-php.sh &" ) || init-php.sh &) [ -x init-php.sh ] && su ${SITE_USER} -s /bin/sh "init-php.sh" &
exec /usr/local/bin/docker-php-entrypoint "$@" exec /usr/local/bin/docker-php-entrypoint "$@"
@ -155,16 +148,22 @@ if [ -r artisan -a -e ${php}/.env ]; then
wait_for_db 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" su ${SITE_USER} -s /bin/sh -c "
( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${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
"
elif [ "$role" = "scheduler" ]; then elif [ "$role" = "scheduler" ]; then
echo " - Running the scheduler..." echo " - Running the scheduler..."
# We'll delay starting in case the app is caching # We'll delay starting in case the app is caching
sleep 15 sleep 15
CMD="while true; do php ${PHP_OPTIONS} artisan schedule:work --verbose --no-interaction; done" su ${SITE_USER} -s /bin/sh -c "
( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD} while true; do
php ${PHP_OPTIONS} artisan schedule:work --verbose --no-interaction
done
"
fi fi
else else