mirror of
https://github.com/pelican-dev/panel.git
synced 2025-12-17 17:11:21 +01:00
Fix migrations in docker container (#1999)
This commit is contained in:
parent
cd3f3a97ac
commit
e2529ab436
@ -1,7 +1,7 @@
|
|||||||
x-common:
|
x-common:
|
||||||
panel:
|
panel:
|
||||||
&panel-environment
|
&panel-environment
|
||||||
APP_URL: "https://localhost" # can be set to 'http://localhost' on port 80 only
|
APP_URL: "http://localhost"
|
||||||
LE_EMAIL: "USEYOUROWNEMAILHERE@example.com" # email to be used for let's encrypt certificates
|
LE_EMAIL: "USEYOUROWNEMAILHERE@example.com" # email to be used for let's encrypt certificates
|
||||||
APP_DEBUG: "false"
|
APP_DEBUG: "false"
|
||||||
APP_ENV: "production"
|
APP_ENV: "production"
|
||||||
|
|||||||
@ -1,14 +1,16 @@
|
|||||||
#!/bin/ash -e
|
#!/bin/ash -e
|
||||||
## check for .env file or symlink and generate app keys if missing
|
# check for .env file or symlink and generate app keys if missing
|
||||||
if [ -f /var/www/html/.env ]; then
|
if [ -f /var/www/html/.env ]; then
|
||||||
echo "external vars exist."
|
echo "external vars exist."
|
||||||
|
# load env vars from .env
|
||||||
|
export $(grep -v '^#' .env | xargs)
|
||||||
else
|
else
|
||||||
echo "external vars don't exist."
|
echo "external vars don't exist."
|
||||||
# webroot .env is symlinked to this path
|
# webroot .env is symlinked to this path
|
||||||
touch /pelican-data/.env
|
touch /pelican-data/.env
|
||||||
|
|
||||||
## manually generate a key because key generate --force fails
|
# manually generate a key because key generate --force fails
|
||||||
if [ -z $APP_KEY ]; then
|
if [ -z ${APP_KEY} ]; then
|
||||||
echo -e "Generating key."
|
echo -e "Generating key."
|
||||||
APP_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
APP_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
||||||
echo -e "Generated app key: $APP_KEY"
|
echo -e "Generated app key: $APP_KEY"
|
||||||
@ -18,17 +20,28 @@ else
|
|||||||
echo -e "APP_KEY=$APP_KEY" > /pelican-data/.env
|
echo -e "APP_KEY=$APP_KEY" > /pelican-data/.env
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## enable installer
|
# enable installer
|
||||||
echo -e "APP_INSTALLED=false" >> /pelican-data/.env
|
echo -e "APP_INSTALLED=false" >> /pelican-data/.env
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# create directories for volumes
|
||||||
mkdir -p /pelican-data/database /pelican-data/storage/avatars /pelican-data/storage/fonts /var/www/html/storage/logs/supervisord 2>/dev/null
|
mkdir -p /pelican-data/database /pelican-data/storage/avatars /pelican-data/storage/fonts /var/www/html/storage/logs/supervisord 2>/dev/null
|
||||||
|
|
||||||
if ! grep -q "APP_KEY=" .env || grep -q "APP_KEY=$" .env; then
|
# if the app is installed then we need to run migrations on start. New installs will run migrations when you run the installer.
|
||||||
echo "Generating APP_KEY..."
|
if [ "${APP_INSTALLED}" == "true" ]; then
|
||||||
php artisan key:generate --force
|
#if the db is anything but sqlite wait until it's accepting connections
|
||||||
else
|
if [ "${DB_CONNECTION}" != "sqlite" ]; then
|
||||||
echo "APP_KEY is already set."
|
# check for DB up before starting the panel
|
||||||
|
echo "Checking database status."
|
||||||
|
until nc -z -v -w30 $DB_HOST $DB_PORT
|
||||||
|
do
|
||||||
|
echo "Waiting for database connection..."
|
||||||
|
# wait for 1 seconds before check again
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
# run migration
|
||||||
|
php artisan migrate --force
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "Optimizing Filament"
|
echo -e "Optimizing Filament"
|
||||||
@ -36,11 +49,16 @@ php artisan filament:optimize
|
|||||||
|
|
||||||
# default to caddy not starting
|
# default to caddy not starting
|
||||||
export SUPERVISORD_CADDY=false
|
export SUPERVISORD_CADDY=false
|
||||||
export PARSED_LE_EMAIL="email ${LE_EMAIL}"
|
|
||||||
export PARSED_APP_URL=${APP_URL}
|
export PARSED_APP_URL=${APP_URL}
|
||||||
|
|
||||||
|
# checking if app url is using https
|
||||||
|
if echo "${APP_URL}" | grep -qE '^https://'; then
|
||||||
|
echo "https domain found setting email var"
|
||||||
|
export PARSED_LE_EMAIL="email ${LE_EMAIL}"
|
||||||
|
fi
|
||||||
|
|
||||||
# when running behind a proxy
|
# when running behind a proxy
|
||||||
if [[ ${BEHIND_PROXY} == "true" ]]; then
|
if [ "${BEHIND_PROXY}" == "true" ]; then
|
||||||
echo "running behind proxy"
|
echo "running behind proxy"
|
||||||
echo "listening on port 80 internally"
|
echo "listening on port 80 internally"
|
||||||
export PARSED_LE_EMAIL=""
|
export PARSED_LE_EMAIL=""
|
||||||
@ -49,16 +67,16 @@ if [[ ${BEHIND_PROXY} == "true" ]]; then
|
|||||||
export ASSET_URL=${APP_URL}
|
export ASSET_URL=${APP_URL}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## disable caddy if SKIP_CADDY is set
|
# disable caddy if SKIP_CADDY is set
|
||||||
if [[ "${SKIP_CADDY:-}" == "true" ]]; then
|
if [ "${SKIP_CADDY:-}" == "true" ]; then
|
||||||
echo "Starting PHP-FPM only"
|
echo "Starting PHP-FPM only"
|
||||||
else
|
else
|
||||||
echo "Starting PHP-FPM and Caddy"
|
echo "Starting PHP-FPM and Caddy"
|
||||||
# enable caddy
|
# enable caddy
|
||||||
export SUPERVISORD_CADDY=true
|
export SUPERVISORD_CADDY=true
|
||||||
|
|
||||||
# handle trusted proxies for caddy
|
# handle trusted proxies for caddy when variable has data
|
||||||
if [[ ! -z ${TRUSTED_PROXIES} ]]; then
|
if [ ! -z ${TRUSTED_PROXIES} ]; then
|
||||||
export CADDY_TRUSTED_PROXIES=$(echo "trusted_proxies static ${TRUSTED_PROXIES}" | sed 's/,/ /g')
|
export CADDY_TRUSTED_PROXIES=$(echo "trusted_proxies static ${TRUSTED_PROXIES}" | sed 's/,/ /g')
|
||||||
export CADDY_STRICT_PROXIES="trusted_proxies_strict"
|
export CADDY_STRICT_PROXIES="trusted_proxies_strict"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user