Merge entrypoints

This commit is contained in:
Philipp Lang 2023-07-24 17:34:38 +02:00
parent f11226b0a1
commit 5bd99b47b6
7 changed files with 41 additions and 46 deletions

View File

@ -1,13 +0,0 @@
#!/bin/bash
set -e
# ------------------------- check for database access -------------------------
function wait_for_db {
while true; do
echo "waiting for Database init"
php -r 'new PDO("mysql:host='$DB_HOST';dbname='$DB_DATABASE'", "'$DB_USERNAME'", "'$DB_PASSWORD'");' > /dev/null && return 0
done
}
su www-data -c 'php artisan horizon' -s /bin/sh

View File

@ -1,30 +0,0 @@
#!/bin/bash
set -e
# --------------------------- ensure appkey is set ----------------------------
if [ $APP_KEY = "YOUR_APP_KEY" ]; then
echo "----------------------- Keinen APP KEY gefunden. Key wird generiert: $(php artisan key:generate --show) ----------------------- Füge diesen Key als APP_KEY ein ---------------------"
exit 1
fi
# ------------------------- check for database access -------------------------
function wait_for_db {
while true; do
echo "waiting for Database init"
php -r 'new PDO("mysql:host='$DB_HOST';dbname='$DB_DATABASE'", "'$DB_USERNAME'", "'$DB_PASSWORD'");' > /dev/null && return 0
sleep 1
done
}
wait_for_db
php -r '$connection = new PDO("mysql:host='$DB_HOST';dbname='$DB_DATABASE'", "'$DB_USERNAME'", "'$DB_PASSWORD'"); $connection->query("DESCRIBE migrations");' > /dev/null || php artisan migrate --seed --force
php artisan migrate --force
mkdir /app/packages/laravel-nami/.cookies || true
mkdir /app/storage/app || true
chown -R www-data:www-data /app/packages/laravel-nami/.cookies
chown -R www-data:www-data /app/storage/app
php-fpm -F -R -O

View File

@ -18,14 +18,14 @@ RUN pecl install redis && docker-php-ext-enable redis
COPY --chown=www-data:www-data . /app
COPY --chown=www-data:www-data --from=node /app/public /app/public
COPY --chown=www-data:www-data --from=composer /app/vendor /app/vendor
RUN usermod -s /bin/bash www-data
USER www-data
RUN php artisan telescope:publish
RUN php artisan horizon:publish
USER root
COPY ./.docker/php-entrypoint /bin/php-entrypoint
COPY ./.docker/horizon-entrypoint /bin/horizon-entrypoint
COPY ./.docker/php /bin
VOLUME ["/app/packages/laravel-nami/.cookies", "/app/storage/app"]

35
.docker/php/entrypoint Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
set -e
function wait_for_db {
while true; do
echo "waiting for Database init"
php -r 'new PDO("mysql:host='$DB_HOST';dbname='$DB_DATABASE'", "'$DB_USERNAME'", "'$DB_PASSWORD'");' > /dev/null && return 0
sleep 1
done
}
mkdir /app/packages/laravel-nami/.cookies || true
mkdir /app/storage/app || true
chown -R www-data:www-data /app/packages/laravel-nami/.cookies
chown -R www-data:www-data /app/storage/app
if [ $1 == "horizon" ]; then
wait_for_db
su www-data -c 'php artisan horizon'
fi
if [ $1 == "app" ]; then
# --------------------------- ensure appkey is set ----------------------------
if [ $APP_KEY = "YOUR_APP_KEY" ]; then
echo "----------------------- Keinen APP KEY gefunden. Key wird generiert: $(su www-data -c 'php artisan key:generate --show') ----------------------- Füge diesen Key als APP_KEY ein ---------------------"
exit 1
fi
wait_for_db
php -r '$connection = new PDO("mysql:host='$DB_HOST';dbname='$DB_DATABASE'", "'$DB_USERNAME'", "'$DB_PASSWORD'"); $connection->query("DESCRIBE migrations");' > /dev/null || php artisan migrate --seed --force
su www-data -c 'php artisan migrate --force'
php-fpm -F -R -O
fi

View File

@ -8,3 +8,4 @@ bootstrap/cache/packages.php
bootstrap/cache/routes.php
packages/laravel-nami/.cookies
app/storage/app
cookies

1
.gitignore vendored
View File

@ -24,3 +24,4 @@ resources/img/sprite.svg
/.php-cs-fixer.cache
/data
.app.env
cookies

View File

@ -17,6 +17,7 @@ services:
dockerfile: ./.docker/php.Dockerfile
depends_on:
- db
command: /bin/entrypoint app
env_file:
- .app.env
environment:
@ -38,7 +39,7 @@ services:
depends_on:
- db
- php
command: /bin/horizon-entrypoint
command: /bin/entrypoint horizon
env_file:
- .app.env
environment: