mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
improve docker init check
This commit is contained in:
@@ -76,12 +76,17 @@ if [ "$USE_HTTPS" = "0" ]; then
|
|||||||
echo_info "remove https related configuration ..."
|
echo_info "remove https related configuration ..."
|
||||||
sed -i '/ssl_certificate/d' "$APP_CONF"
|
sed -i '/ssl_certificate/d' "$APP_CONF"
|
||||||
sed -i '/http2/d' "$APP_CONF"
|
sed -i '/http2/d' "$APP_CONF"
|
||||||
sed -i 's/listen.*/listen 80;/g' "$APP_CONF"
|
sed -i "s/listen.*/listen $NP_PORT;/g" "$APP_CONF"
|
||||||
|
|
||||||
sed -i '/ssl_certificate/d' "$PMA_CONF"
|
sed -i '/ssl_certificate/d' "$PMA_CONF"
|
||||||
sed -i '/http2/d' "$PMA_CONF"
|
sed -i '/http2/d' "$PMA_CONF"
|
||||||
sed -i 's/listen.*/listen 80;/g' "$PMA_CONF"
|
sed -i "s/listen.*/listen $NP_PORT;/g" "$PMA_CONF"
|
||||||
|
else
|
||||||
|
sed -i "s/listen.*/listen $NP_PORT ssl;/g" "$APP_CONF"
|
||||||
|
sed -i "s/listen.*/listen $NP_PORT ssl;/g" "$PMA_CONF"
|
||||||
fi
|
fi
|
||||||
|
cat $APP_CONF
|
||||||
|
cat $PMA_CONF
|
||||||
|
|
||||||
openresty -T
|
openresty -T
|
||||||
|
|
||||||
|
|||||||
@@ -57,26 +57,29 @@ ROOT_PATH="/var/www/html"
|
|||||||
SOURCE_DIR="${ROOT_PATH}/nexus/Install/install"
|
SOURCE_DIR="${ROOT_PATH}/nexus/Install/install"
|
||||||
TARGET_DIR="${ROOT_PATH}/public"
|
TARGET_DIR="${ROOT_PATH}/public"
|
||||||
ENV_FILE="${ROOT_PATH}/.env"
|
ENV_FILE="${ROOT_PATH}/.env"
|
||||||
VENDOR_DIR="${ROOT_PATH}/vendor"
|
VENDOR_AUTOLOAD_FILE="${ROOT_PATH}/vendor/autoload.php"
|
||||||
|
|
||||||
chown -R www-data:www-data $ROOT_PATH
|
chown -R www-data:www-data $ROOT_PATH
|
||||||
|
|
||||||
if [ "$SERVICE_NAME" = "php" ]; then
|
if [ "$SERVICE_NAME" = "php" ]; then
|
||||||
if [ ! -f "$ENV_FILE" ]; then
|
if [ ! -f "$ENV_FILE" ] || [ ! -f "$VENDOR_AUTOLOAD_FILE" ]; then
|
||||||
echo_info ".env file: $ENV_FILE not exists, copy $SOURCE_DIR to $TARGET_DIR ..."
|
echo_info ".env file: $ENV_FILE or vendor autoload file: $VENDOR_AUTOLOAD_FILE not exists, copy $SOURCE_DIR to $TARGET_DIR ..."
|
||||||
cp -r "$SOURCE_DIR" "$TARGET_DIR"
|
cp -r "$SOURCE_DIR" "$TARGET_DIR"
|
||||||
sed -i 's|LOG_FILE.*|LOG_FILE=php://stdout|g' "$ROOT_PATH/.env.example"
|
sed -i 's|LOG_FILE.*|LOG_FILE=php://stdout|g' "$ROOT_PATH/.env.example"
|
||||||
|
if [ -f "$ENV_FILE" ]; then
|
||||||
|
sed -i 's|LOG_FILE.*|LOG_FILE=php://stdout|g' "$ENV_FILE"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo_success ".env file: $ENV_FILE already exists, skip copy install file ..."
|
echo_success ".env file: $ENV_FILE and vendor autoload file: $VENDOR_AUTOLOAD_FILE already exists, skip copy install file ..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# composer install
|
# composer install
|
||||||
if [ ! -d "$VENDOR_DIR" ]; then
|
if [ ! -f "$VENDOR_AUTOLOAD_FILE" ]; then
|
||||||
echo_info "vendor dir: $VENDOR_DIR not exists, run composer install ..."
|
echo_info "vendor autoload file: $VENDOR_AUTOLOAD_FILE not exists, run composer install ..."
|
||||||
git config --global --add safe.directory ${ROOT_PATH}
|
git config --global --add safe.directory ${ROOT_PATH}
|
||||||
composer install --working-dir=${ROOT_PATH}
|
composer install --working-dir=${ROOT_PATH}
|
||||||
else
|
else
|
||||||
echo_success "vendor dir: $VENDOR_DIR already exists, skip run composer install ..."
|
echo_success "vendor autoload file: $VENDOR_AUTOLOAD_FILE already exists, skip run composer install ..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 最后启动 PHP-FPM
|
# 最后启动 PHP-FPM
|
||||||
@@ -84,8 +87,8 @@ if [ "$SERVICE_NAME" = "php" ]; then
|
|||||||
elif [ "$SERVICE_NAME" = "queue" ]; then
|
elif [ "$SERVICE_NAME" = "queue" ]; then
|
||||||
echo_info "Start Queue Worker...";
|
echo_info "Start Queue Worker...";
|
||||||
while true; do
|
while true; do
|
||||||
if [ -f "$ENV_FILE" ] && [ -d "$VENDOR_DIR" ]; then
|
if [ -f "$ENV_FILE" ] && [ -f "$VENDOR_AUTOLOAD_FILE" ]; then
|
||||||
echo_success "[Queue] Run queue:work at $(date '+%Y-%m-%d %H:%M:%S')";
|
echo_success "[Queue] env: $ENV_FILE and vendor autoload file: $VENDOR_AUTOLOAD_FILE exists, Run horizon at $(date '+%Y-%m-%d %H:%M:%S')";
|
||||||
php artisan horizon;
|
php artisan horizon;
|
||||||
else
|
else
|
||||||
echo_info "[Queue] .env or vendor not exists,wait 5 seconds ...";
|
echo_info "[Queue] .env or vendor not exists,wait 5 seconds ...";
|
||||||
@@ -95,8 +98,8 @@ elif [ "$SERVICE_NAME" = "queue" ]; then
|
|||||||
elif [ "$SERVICE_NAME" = "scheduler" ]; then
|
elif [ "$SERVICE_NAME" = "scheduler" ]; then
|
||||||
echo_info "Start Scheduler ...";
|
echo_info "Start Scheduler ...";
|
||||||
while true; do
|
while true; do
|
||||||
if [ -f "$ENV_FILE" ] && [ -d "$VENDOR_DIR" ]; then
|
if [ -f "$ENV_FILE" ] && [ -f "$VENDOR_AUTOLOAD_FILE" ]; then
|
||||||
echo_success "[Scheduler] Run schedule:run at $(date '+%Y-%m-%d %H:%M:%S')";
|
echo_success "[Scheduler] env: $ENV_FILE and vendor autoload file: $VENDOR_AUTOLOAD_FILE exists, Run schedule:run at $(date '+%Y-%m-%d %H:%M:%S')";
|
||||||
php artisan schedule:run --verbose --no-interaction;
|
php artisan schedule:run --verbose --no-interaction;
|
||||||
sleep 60;
|
sleep 60;
|
||||||
else
|
else
|
||||||
@@ -107,8 +110,8 @@ elif [ "$SERVICE_NAME" = "scheduler" ]; then
|
|||||||
elif [ "$SERVICE_NAME" = "cleanup" ]; then
|
elif [ "$SERVICE_NAME" = "cleanup" ]; then
|
||||||
echo_info "Start Cleanup ...";
|
echo_info "Start Cleanup ...";
|
||||||
while true; do
|
while true; do
|
||||||
if [ -f "$ENV_FILE" ] && [ -d "$VENDOR_DIR" ]; then
|
if [ -f "$ENV_FILE" ] && [ -f "$VENDOR_AUTOLOAD_FILE" ]; then
|
||||||
echo_success "[Cleanup] Run cleanup:run at $(date '+%Y-%m-%d %H:%M:%S')";
|
echo_success "[Cleanup] env: $ENV_FILE and vendor autoload file: $VENDOR_AUTOLOAD_FILE exists, Run cleanup at $(date '+%Y-%m-%d %H:%M:%S')";
|
||||||
php include/cleanup_cli.php;
|
php include/cleanup_cli.php;
|
||||||
sleep 60;
|
sleep 60;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ services:
|
|||||||
container_name: nexusphp-openresty
|
container_name: nexusphp-openresty
|
||||||
environment:
|
environment:
|
||||||
NP_DOMAIN: ${NP_DOMAIN:-localhost}
|
NP_DOMAIN: ${NP_DOMAIN:-localhost}
|
||||||
|
NP_PORT: ${NP_PORT:-80}
|
||||||
volumes:
|
volumes:
|
||||||
- ./.docker/openresty/sites:/etc/nginx/conf.d/sites
|
- ./.docker/openresty/sites:/etc/nginx/conf.d/sites
|
||||||
- ./.docker/openresty/certs:/certs
|
- ./.docker/openresty/certs:/certs
|
||||||
|
|||||||
Reference in New Issue
Block a user