Added .gitignore and initial Laravel setup
This commit is contained in:
parent
32e2e416cb
commit
f0eab930f1
|
@ -19,6 +19,7 @@
|
|||
/src/vendor
|
||||
.env
|
||||
.env.backup
|
||||
*.log
|
||||
>>>>>>> c760080 (Initial Laravel Docker setup)
|
||||
.phpunit.result.cache
|
||||
Homestead.json
|
||||
|
|
53
Dockerfile
53
Dockerfile
|
@ -1,28 +1,55 @@
|
|||
FROM php:8.2-fpm
|
||||
FROM php:8.2
|
||||
|
||||
# Install dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libpng-dev \
|
||||
libjpeg-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libfreetype6-dev \
|
||||
zip \
|
||||
libzip-dev \
|
||||
unzip \
|
||||
git \
|
||||
bison \
|
||||
curl \
|
||||
libxml2-dev \
|
||||
php8.2-tokenizer \
|
||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
&& docker-php-ext-install gd pdo pdo_mysql
|
||||
&& docker-php-ext-install -j$(nproc) \
|
||||
gd \
|
||||
pdo_mysql \
|
||||
zip \
|
||||
tokenizer \
|
||||
mbstring \
|
||||
xml \
|
||||
bcmath \
|
||||
dom \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Configure PHP-FPM
|
||||
RUN echo "[global]\nerror_log = /proc/self/fd/2\n[www]\nlisten = 0.0.0.0:9000\npm = dynamic\npm.max_children = 5\npm.start_servers = 2\npm.min_spare_servers = 1\npm.max_spare_servers = 3" > /usr/local/etc/php-fpm.d/zzz-custom.conf
|
||||
|
||||
# Copy entrypoint script
|
||||
COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
# Install Composer
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# Copy the application code
|
||||
COPY . .
|
||||
# Copy composer files first to leverage Docker cache
|
||||
COPY composer.json composer.lock* ./
|
||||
|
||||
# Install Laravel dependencies
|
||||
RUN composer install --no-dev --optimize-autoloader
|
||||
RUN composer install --optimize-autoloader --no-dev --ignore-platform-reqs
|
||||
|
||||
# Expose port
|
||||
EXPOSE 9000
|
||||
# Copy the rest of the Laravel application files
|
||||
COPY . /var/www/html
|
||||
|
||||
CMD ["php-fpm"]
|
||||
# Set permissions
|
||||
RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache \
|
||||
&& chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
|
||||
|
||||
# Set the entrypoint
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
|
|
|
@ -12,7 +12,7 @@ services:
|
|||
networks:
|
||||
- app-network
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-proot"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
@ -29,15 +29,15 @@ services:
|
|||
condition: service_healthy
|
||||
volumes:
|
||||
- .:/var/www/html
|
||||
- /var/www/html/vendor
|
||||
networks:
|
||||
- app-network
|
||||
healthcheck:
|
||||
test: ["CMD", "php", "--version"]
|
||||
test: ["CMD", "pidof", "php-fpm"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
command: >
|
||||
sh -c "sleep 10 && php artisan migrate --force && php-fpm"
|
||||
start_period: 30s
|
||||
restart: unless-stopped
|
||||
|
||||
nginx:
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/sh
|
||||
set -x # Enable debug mode to log each command
|
||||
|
||||
echo "Waiting for MySQL..."
|
||||
sleep 20
|
||||
|
||||
echo "Checking for vendor directory..."
|
||||
if [ ! -d "/var/www/html/vendor" ]; then
|
||||
echo "ERROR: vendor directory not found. It should have been created during the build."
|
||||
echo "Attempting to run composer install as a fallback..."
|
||||
if ! composer install --optimize-autoloader --no-dev --ignore-platform-reqs; then
|
||||
echo "ERROR: composer install failed"
|
||||
composer diagnose
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Running migrations..."
|
||||
if ! php artisan migrate --force; then
|
||||
echo "ERROR: php artisan migrate failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Starting PHP-FPM..."
|
||||
exec php-fpm
|
Loading…
Reference in New Issue