Compare commits
2 Commits
daeef13904
...
6e1a90cd50
Author | SHA1 | Date | |
---|---|---|---|
6e1a90cd50 | |||
3daec4b5e6 |
@ -6,32 +6,38 @@ 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 tar zstd
|
||||||
# ## 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
|
||||||
@ -43,19 +49,31 @@ 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
|
||||||
|
public/js/app.js
|
||||||
|
public/js/vendor.js
|
||||||
|
#key: build-pla-page-assets-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
key: build-pla-page-assets
|
||||||
|
#restore-keys: |
|
||||||
|
# build-pla-page-assets-
|
||||||
|
|
||||||
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 }}
|
||||||
@ -72,7 +90,7 @@ jobs:
|
|||||||
# 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 curl nodejs npm
|
apk add git curl nodejs npm tar zstd
|
||||||
# Start docker
|
# Start docker
|
||||||
( dockerd --host=tcp://0.0.0.0:2375 --tls=false & ) && sleep 3
|
( dockerd --host=tcp://0.0.0.0:2375 --tls=false & ) && sleep 3
|
||||||
## Some debugging info
|
## Some debugging info
|
||||||
@ -95,16 +113,35 @@ jobs:
|
|||||||
- name: Code Checkout
|
- name: Code Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Build Assets
|
- name: Cache page assets
|
||||||
|
id: cache-page-assets
|
||||||
|
uses: actions/cache@v3
|
||||||
|
# env:
|
||||||
|
# cache-name: page-assets
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
public/css/app.css
|
||||||
|
public/js/app.js
|
||||||
|
public/js/vendor.js
|
||||||
|
#key: build-pla-page-assets-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
key: build-pla-page-assets
|
||||||
|
#restore-keys: |
|
||||||
|
# build-pla-page-assets-
|
||||||
|
|
||||||
|
- if: ${{ steps.cache-page-assets.outputs.cache-hit != 'true' }}
|
||||||
|
name: List the state of page assets
|
||||||
|
continue-on-error: false
|
||||||
run: |
|
run: |
|
||||||
# Build assets
|
echo CACHE-HIT:${{ steps.cache-page-assets.outputs.cache-hit }}
|
||||||
npm i
|
ls -al public/css/
|
||||||
npm run prod
|
ls -al public/js/
|
||||||
|
|
||||||
- name: Record version and Delete Unnecessary files
|
- name: Record version and Delete Unnecessary files
|
||||||
run: |
|
run: |
|
||||||
echo ${GITHUB_SHA::8} > VERSION
|
echo ${GITHUB_SHA::8} > VERSION
|
||||||
rm -rf .git* tests/ storage/app/test/
|
rm -rf .git* tests/ storage/app/test/
|
||||||
|
ls -al public/css/
|
||||||
|
ls -al public/js/
|
||||||
|
|
||||||
- name: Build and Push Docker Image
|
- name: Build and Push Docker Image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
|
@ -37,3 +37,4 @@ ENV SERVER_NAME=:8080
|
|||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
ENTRYPOINT [ "/sbin/init-docker" ]
|
ENTRYPOINT [ "/sbin/init-docker" ]
|
||||||
|
CMD [ "--config","/etc/caddy/Caddyfile","--adapter","caddyfile" ]
|
||||||
|
@ -6,8 +6,10 @@ 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
|
||||||
|
|
||||||
# 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}
|
||||||
@ -33,6 +35,8 @@ function wait_for_db() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "* Started with [$@]"
|
||||||
|
|
||||||
# Run any container setup
|
# Run any container setup
|
||||||
[ -x /sbin/init-container ] && /sbin/init-container
|
[ -x /sbin/init-container ] && /sbin/init-container
|
||||||
|
|
||||||
@ -87,7 +91,8 @@ 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
|
||||||
|
|
||||||
su ${SITE_USER} -s /bin/sh -c "composer install --optimize-autoloader ${NODEV}" && ( test -e .composer.refresh && rm -f .composer.refresh )
|
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 "${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
|
||||||
|
|
||||||
@ -95,7 +100,8 @@ 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..."
|
||||||
su ${SITE_USER} -s /bin/sh -c "(php artisan optimize)"
|
CMD="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
|
||||||
@ -108,7 +114,8 @@ if [ -r artisan -a -e ${php}/.env ]; then
|
|||||||
|
|
||||||
wait_for_db
|
wait_for_db
|
||||||
|
|
||||||
su ${SITE_USER} -s /bin/sh -c "php artisan migrate" && rm -f .migrate
|
CMD="php artisan 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"
|
||||||
@ -118,20 +125,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
|
||||||
su ${SITE_USER} -s /bin/sh -c "php artisan passport:keys"
|
CMD="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..."
|
||||||
su ${SITE_USER} -s /bin/sh -c "
|
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) &"
|
||||||
(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
|
fi
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
[ -x init-php.sh ] && su ${SITE_USER} -s /bin/sh "init-php.sh" &
|
[ -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 "$@"
|
exec /usr/local/bin/docker-php-entrypoint "$@"
|
||||||
|
|
||||||
@ -148,22 +155,16 @@ if [ -r artisan -a -e ${php}/.env ]; then
|
|||||||
|
|
||||||
wait_for_db
|
wait_for_db
|
||||||
|
|
||||||
su ${SITE_USER} -s /bin/sh -c "
|
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"
|
||||||
while true; do
|
( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD}
|
||||||
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
|
||||||
|
|
||||||
su ${SITE_USER} -s /bin/sh -c "
|
CMD="while true; do php ${PHP_OPTIONS} artisan schedule:work --verbose --no-interaction; done"
|
||||||
while true; do
|
( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD}
|
||||||
php ${PHP_OPTIONS} artisan schedule:work --verbose --no-interaction
|
|
||||||
done
|
|
||||||
"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user