Add Docker support with Dockerfile, docker-compose, and entrypoint script; update .gitignore and add .dockerignore
This commit is contained in:
59
docker/entrypoint.sh
Normal file
59
docker/entrypoint.sh
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
APP_DIR=/var/www/html
|
||||
|
||||
echo "──────────────────────────────────────────"
|
||||
echo " KOL Manager – Container Start"
|
||||
echo "──────────────────────────────────────────"
|
||||
|
||||
cd "$APP_DIR"
|
||||
|
||||
# ── 1. Bootstrap .env ───────────────────────
|
||||
if [ ! -f .env ]; then
|
||||
if [ -f .env.docker ]; then
|
||||
cp .env.docker .env
|
||||
echo "[env] Copied .env.docker → .env"
|
||||
else
|
||||
echo "[env] WARNING: No .env or .env.docker found!"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ── 2. Generate APP_KEY if empty ────────────
|
||||
if grep -qE '^APP_KEY=$' .env 2>/dev/null; then
|
||||
echo "[key] Generating application key…"
|
||||
php artisan key:generate --force --quiet
|
||||
fi
|
||||
|
||||
# ── 3. Ensure SQLite database file exists ───
|
||||
if [ ! -f database/database.sqlite ]; then
|
||||
echo "[db] Creating SQLite database file…"
|
||||
touch database/database.sqlite
|
||||
fi
|
||||
|
||||
# ── 4. Fix ownership / permissions ──────────
|
||||
chown -R www-data:www-data \
|
||||
storage \
|
||||
bootstrap/cache \
|
||||
database
|
||||
chmod -R 775 \
|
||||
storage \
|
||||
bootstrap/cache \
|
||||
database
|
||||
|
||||
# ── 5. Run migrations ────────────────────────
|
||||
echo "[migrate] Running database migrations…"
|
||||
php artisan migrate --force --no-interaction
|
||||
|
||||
# ── 6. Cache config / routes / views ────────
|
||||
echo "[optimize] Caching configuration…"
|
||||
php artisan config:cache --quiet
|
||||
php artisan route:cache --quiet
|
||||
php artisan view:cache --quiet
|
||||
|
||||
echo "──────────────────────────────────────────"
|
||||
echo " All checks passed. Starting services…"
|
||||
echo "──────────────────────────────────────────"
|
||||
|
||||
# ── 7. Hand off to Supervisor ────────────────
|
||||
exec supervisord -c /etc/supervisord.conf
|
||||
Reference in New Issue
Block a user