From 616e31de2daaef32a1c3610f8822475b4e9b6ea2 Mon Sep 17 00:00:00 2001 From: Naterfute Date: Sat, 16 Aug 2025 23:30:34 -0700 Subject: [PATCH] dev: fixed docker dev --- .github/docker/entrypoint.sh | 72 +++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/.github/docker/entrypoint.sh b/.github/docker/entrypoint.sh index a830090e2..92ee0f7ad 100644 --- a/.github/docker/entrypoint.sh +++ b/.github/docker/entrypoint.sh @@ -105,8 +105,76 @@ else echo -e "Skipping database seeding (SKIP_SEED=True)" fi -# Development setup is now handled by the DevelopmentSeeder -# Run: php artisan db:seed --class=DevelopmentSeeder +# Setup development environment if specified +( + source /app/.env + if [ "$PYRODACTYL_DOCKER_DEV" = "true" ] && [ "$DEV_SETUP" != "true" ]; then + echo -e "\e[42mDevelopment environment detected, setting up development resources...\e[0m" + + # Create a developer user + php artisan p:user:make -n --email dev@pyro.host --username dev --name-first Developer --name-last User --password password + mariadb -u root -h database -p"$DB_ROOT_PASSWORD" --ssl=0 -e "USE panel; UPDATE users SET root_admin = 1;" # workaround because --admin is broken + + # Make a location and node for the panel + php artisan p:location:make -n --short local --long Local + php artisan p:node:make -n --name local --description "Development Node" --locationId 1 --fqdn localhost --internal-fqdn $WINGS_INTERNAL_IP --public 1 --scheme http --proxy 0 --maxMemory 1024 --maxDisk 10240 --overallocateMemory 0 --overallocateDisk 0 + + echo "Adding dummy allocations..." + mariadb -u root -h database -p"$DB_ROOT_PASSWORD" --ssl=0 -e "USE panel; INSERT INTO allocations (node_id, ip, port) VALUES (1, '0.0.0.0', 25565), (1, '0.0.0.0', 25566), (1, '0.0.0.0', 25567);" + + echo "Creating database user..." + mariadb -u root -h database -p"$DB_ROOT_PASSWORD" --ssl=0 -e "CREATE USER 'pterodactyluser'@'%' IDENTIFIED BY 'somepassword'; GRANT ALL PRIVILEGES ON *.* TO 'pterodactyluser'@'%' WITH GRANT OPTION;" + + # Configure node + export WINGS_CONFIG=/etc/pterodactyl/config.yml + mkdir -p $(dirname $WINGS_CONFIG) + echo "Fetching and modifying Wings configuration file..." + CONFIG=$(php artisan p:node:configuration 1) + + # Allow all origins for CORS + CONFIG=$(printf "%s\nallowed_origins: ['*']" "$CONFIG") + + # Update Wings configuration paths if WINGS_DIR is set + if [ -z "$WINGS_DIR" ]; then + echo "WINGS_DIR is not set, using default paths." + else + echo "Updating Wings configuration paths to '$WINGS_DIR'..." + + # add system section if it doesn't exist + if ! echo "$CONFIG" | grep -q "^system:"; then + CONFIG=$(printf "%s\nsystem:" "$CONFIG") + fi + + update_config() { + local key="$1" + local value="$2" + + # update existing key or add new one + if echo "$CONFIG" | grep -q "^ $key:"; then + CONFIG=$(echo "$CONFIG" | sed "s|^ $key:.*| $key: $value|") + else + CONFIG=$(echo "$CONFIG" | sed "/^system:/a\\ $key: $value") + fi + } + + update_config "root_directory" "$WINGS_DIR/srv/wings/" + update_config "log_directory" "$WINGS_DIR/srv/wings/logs/" + update_config "data" "$WINGS_DIR/srv/wings/volumes" + update_config "archive_directory" "$WINGS_DIR/srv/wings/archives" + update_config "backup_directory" "$WINGS_DIR/srv/wings/backups" + update_config "tmp_directory" "$WINGS_DIR/srv/wings/tmp/" + fi + + echo "Saving Wings configuration file to '$WINGS_CONFIG'..." + echo "$CONFIG" > $WINGS_CONFIG + + # Mark setup as complete + echo "DEV_SETUP=true" >> /app/.env + echo "Development setup complete." + elif [ "$DEV_SETUP" = "true" ]; then + echo "Skipping development setup, already completed." + fi +) ## start cronjobs for the queue echo -e "Starting cron jobs."