Primo commit
This commit is contained in:
@@ -55,6 +55,10 @@ COPY php.ini /usr/local/etc/php/conf.d/custom.ini
|
|||||||
# Copy PHP-FPM pool config (run workers as appuser)
|
# Copy PHP-FPM pool config (run workers as appuser)
|
||||||
COPY www.conf /usr/local/etc/php-fpm.d/www.conf
|
COPY www.conf /usr/local/etc/php-fpm.d/www.conf
|
||||||
|
|
||||||
|
# Copy entrypoint
|
||||||
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
# Set ownership
|
# Set ownership
|
||||||
RUN chown -R appuser:appuser /var/www/html
|
RUN chown -R appuser:appuser /var/www/html
|
||||||
|
|
||||||
@@ -62,4 +66,5 @@ USER appuser
|
|||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
|
|
||||||
|
ENTRYPOINT ["entrypoint.sh"]
|
||||||
CMD ["php-fpm"]
|
CMD ["php-fpm"]
|
||||||
|
|||||||
93
docker/php/entrypoint.sh
Executable file
93
docker/php/entrypoint.sh
Executable file
@@ -0,0 +1,93 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "========================================="
|
||||||
|
echo " TerManager2 - Entrypoint"
|
||||||
|
echo "========================================="
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
# 1. Composer install
|
||||||
|
# -----------------------------------------------
|
||||||
|
if [ ! -f vendor/autoload.php ]; then
|
||||||
|
echo "[*] Installing Composer dependencies..."
|
||||||
|
composer install --no-interaction --optimize-autoloader
|
||||||
|
else
|
||||||
|
echo "[✓] Composer dependencies already installed."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
# 2. .env file
|
||||||
|
# -----------------------------------------------
|
||||||
|
if [ ! -f .env ]; then
|
||||||
|
echo "[*] Creating .env from .env.example..."
|
||||||
|
cp .env.example .env
|
||||||
|
else
|
||||||
|
echo "[✓] .env file already exists."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
# 3. Application key
|
||||||
|
# -----------------------------------------------
|
||||||
|
if grep -q "^APP_KEY=$" .env; then
|
||||||
|
echo "[*] Generating application key..."
|
||||||
|
php artisan key:generate --ansi
|
||||||
|
else
|
||||||
|
echo "[✓] Application key already set."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
# 4. NPM install & build assets
|
||||||
|
# -----------------------------------------------
|
||||||
|
if [ ! -d node_modules ]; then
|
||||||
|
echo "[*] Installing NPM dependencies..."
|
||||||
|
npm ci
|
||||||
|
else
|
||||||
|
echo "[✓] NPM dependencies already installed."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d public/build ]; then
|
||||||
|
echo "[*] Building frontend assets..."
|
||||||
|
npm run build
|
||||||
|
else
|
||||||
|
echo "[✓] Frontend assets already built."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
# 5. Storage link
|
||||||
|
# -----------------------------------------------
|
||||||
|
if [ ! -L public/storage ]; then
|
||||||
|
echo "[*] Creating storage symlink..."
|
||||||
|
php artisan storage:link
|
||||||
|
else
|
||||||
|
echo "[✓] Storage symlink already exists."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
# 6. Create required storage directories
|
||||||
|
# -----------------------------------------------
|
||||||
|
mkdir -p storage/framework/{cache,sessions,views}
|
||||||
|
mkdir -p storage/logs
|
||||||
|
mkdir -p bootstrap/cache
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
# 7. Run migrations
|
||||||
|
# -----------------------------------------------
|
||||||
|
echo "[*] Running database migrations..."
|
||||||
|
php artisan migrate --force
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
# 8. Cache config/routes/views
|
||||||
|
# -----------------------------------------------
|
||||||
|
echo "[*] Caching configuration..."
|
||||||
|
php artisan config:cache
|
||||||
|
php artisan route:cache
|
||||||
|
php artisan view:cache
|
||||||
|
|
||||||
|
echo "========================================="
|
||||||
|
echo " TerManager2 - Ready!"
|
||||||
|
echo "========================================="
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
# Execute CMD (default: php-fpm)
|
||||||
|
# -----------------------------------------------
|
||||||
|
exec "$@"
|
||||||
Reference in New Issue
Block a user