From fbcfaf47d85c79a3cd84f57b04a3f6659feed6bb Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Sat, 15 Mar 2025 06:54:24 +0700 Subject: [PATCH] fix: deploy fail --- tastyigniter/Dockerfile | 16 +++++++++------- tastyigniter/README.md | 13 +++++++++++++ tastyigniter/docker/entrypoint.sh | 16 +++++++++++++++- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/tastyigniter/Dockerfile b/tastyigniter/Dockerfile index 6d83fd3..bc7f220 100644 --- a/tastyigniter/Dockerfile +++ b/tastyigniter/Dockerfile @@ -8,6 +8,7 @@ RUN apt-get update && apt-get install -y \ libonig-dev \ libxml2-dev \ libzip-dev \ + libicu-dev \ zip \ unzip \ default-mysql-client @@ -16,7 +17,7 @@ RUN apt-get update && apt-get install -y \ RUN apt-get clean && rm -rf /var/lib/apt/lists/* # Install PHP extensions -RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip xml +RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip xml intl # Get latest Composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer @@ -24,17 +25,18 @@ COPY --from=composer:latest /usr/bin/composer /usr/bin/composer # Set working directory WORKDIR /var/www/html -# Create tastyigniter project (when container is first built) -RUN composer create-project tastyigniter/tastyigniter:^v4.0 /var/www/html --prefer-dist --no-interaction --no-progress - -# Set file permissions -RUN chown -R www-data:www-data /var/www/html -RUN chmod -R 755 /var/www/html/storage +# Instead of running composer create-project during build, we'll do it in the entrypoint +# This allows us to pass the --ignore-platform-req flag if needed # Copy custom entrypoint COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh RUN chmod +x /usr/local/bin/entrypoint.sh +# Set file permissions for the eventual app directory +RUN mkdir -p /var/www/html/storage && \ + chown -R www-data:www-data /var/www/html && \ + chmod -R 755 /var/www/html + # Entrypoint script ENTRYPOINT ["entrypoint.sh"] diff --git a/tastyigniter/README.md b/tastyigniter/README.md index 9b9db08..0772457 100644 --- a/tastyigniter/README.md +++ b/tastyigniter/README.md @@ -89,3 +89,16 @@ If you encounter issues: 2. Verify database connectivity: `docker-compose exec app php artisan db:monitor` 3. Check container status: `docker-compose ps` 4. Ensure proper permissions on the storage directory + +### Common Issues + +**Missing PHP extensions** + +If you see errors about missing PHP extensions like `ext-intl`, the Dockerfile has been updated to include this. However, if you encounter other missing extensions, you can add them to the Dockerfile by: + +1. Adding the required dev packages to the `apt-get install` command +2. Adding the extension to the `docker-php-ext-install` command + +**Composer installation failures** + +If the composer installation fails, you can modify the entrypoint script to use the `--ignore-platform-req` flag. This is included as a fallback in the updated entrypoint script. diff --git a/tastyigniter/docker/entrypoint.sh b/tastyigniter/docker/entrypoint.sh index 5341346..a13e3a9 100644 --- a/tastyigniter/docker/entrypoint.sh +++ b/tastyigniter/docker/entrypoint.sh @@ -1,6 +1,20 @@ #!/bin/bash set -e +# Check if TastyIgniter is already installed +if [ ! -f /var/www/html/composer.json ] || [ ! -d /var/www/html/vendor ]; then + echo "Installing TastyIgniter..." + # Create new TastyIgniter project with fallback for handling extension requirements + composer create-project tastyigniter/tastyigniter:^v4.0 /tmp/tastyigniter --prefer-dist --no-interaction --no-progress || \ + composer create-project tastyigniter/tastyigniter:^v4.0 /tmp/tastyigniter --prefer-dist --no-interaction --no-progress --ignore-platform-req=ext-intl + + # Move files to web root + cp -a /tmp/tastyigniter/. /var/www/html/ + rm -rf /tmp/tastyigniter + + echo "TastyIgniter files installed" +fi + # Generate app key if not set if [ -z "$APP_KEY" ]; then php artisan key:generate @@ -15,7 +29,7 @@ echo "Database connection established" # Run TastyIgniter installer in non-interactive mode if [ ! -f .env ] || ! grep -q "IGNITER_INSTALLED=true" .env; then - echo "Installing TastyIgniter..." + echo "Running TastyIgniter installer..." php artisan igniter:install --no-interaction # Mark as installed in .env