Setup done

This commit is contained in:
Shadchamp
2025-08-28 13:31:53 -04:00
parent 9306a1492e
commit abe059f0ab
2 changed files with 37 additions and 10 deletions
+11 -1
View File
@@ -32,4 +32,14 @@ services:
- ./UNIT3D:/var/www/html
env_file:
- .env
entrypoint: /entrypoint.sh debug
entrypoint: /entrypoint.sh debug
unit3d-backup:
image: unit3d:latest
volumes:
- ./backup:/backup
- ./mysql:/var/lib/mysql:ro
- ./UNIT3D:/var/www/html:ro
env_file:
- .env
entrypoint: /entrypoint.sh backup-mysql
+26 -9
View File
@@ -4,9 +4,9 @@ if [[ "$1" == "setup" ]]; then
echo "Setting up UNIT3D..."
# Run setup commands here
cd /var/www/html
#composer install --no-interaction --prefer-dist
#php artisan key:generate
#echo "Please save this to APP_KEY in UNIT3D/.env"
composer install --no-interaction --prefer-dist
php artisan key:generate
echo "Please save this to APP_KEY in UNIT3D/.env"
echo "Setting correct permissions for MariaDB data directory..."
sudo chown -R mysql:mysql /var/lib/mysql
sudo chmod -R 750 /var/lib/mysql
@@ -18,10 +18,6 @@ if [[ "$1" == "setup" ]]; then
su -s /bin/bash mysql -c "mysql_install_db --basedir=/usr --datadir=/var/lib/mysql"
fi
# Prevent tail from running on /dev/null, use a log file instead
# Example: tail MariaDB log file to keep container alive and show logs
su -s /bin/bash mysql -c "mysqld &"
# Wait for MariaDB to be ready
until mysqladmin ping -h "localhost" --silent; do
@@ -32,13 +28,34 @@ if [[ "$1" == "setup" ]]; then
# Keep MariaDB running in the background
php artisan migrate:fresh --seed
npm install -g bun || npm update -g bun
#npm install
#npm run build
bun install
bun pm untrusted
bun pm trust --all
bun install
bun run build
php artisan set:all_cache
php artisan queue:restart
fi
if [[ "$1" == "debug" ]]; then
echo "Debug mode: keeping container running..."
tail -f /dev/null
fi
if [[ "$1" == "backup-mysql" ]]; then
BACKUP_DIR="/backup"
BACKUP_FILE="$BACKUP_DIR/mysql-$(date +%Y%m%d-%H%M%S).sql"
mkdir -p "$BACKUP_DIR"
echo "Backing up MySQL database to $BACKUP_FILE..."
mysqldump --all-databases --single-transaction --quick --lock-tables=false -u root > "$BACKUP_FILE"
if [[ $? -eq 0 ]]; then
echo "Backup completed successfully."
else
echo "Backup failed."
exit 1
fi
fi
if [[ -z "$1" ]]; then
echo "Starting Nginx with /etc/nginx/conf.d/unit3d.conf..."
nginx -c /etc/nginx/conf.d/unit3d.conf