Added .gitignore and initial Laravel setup
This commit is contained in:
parent
32e2e416cb
commit
f0eab930f1
|
@ -19,6 +19,7 @@
|
||||||
/src/vendor
|
/src/vendor
|
||||||
.env
|
.env
|
||||||
.env.backup
|
.env.backup
|
||||||
|
*.log
|
||||||
>>>>>>> c760080 (Initial Laravel Docker setup)
|
>>>>>>> c760080 (Initial Laravel Docker setup)
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
Homestead.json
|
Homestead.json
|
||||||
|
|
53
Dockerfile
53
Dockerfile
|
@ -1,28 +1,55 @@
|
||||||
FROM php:8.2-fpm
|
FROM php:8.2
|
||||||
|
|
||||||
# Install dependencies
|
# Install system dependencies
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
libpng-dev \
|
libpng-dev \
|
||||||
libjpeg-dev \
|
libjpeg62-turbo-dev \
|
||||||
libfreetype6-dev \
|
libfreetype6-dev \
|
||||||
zip \
|
libzip-dev \
|
||||||
unzip \
|
unzip \
|
||||||
|
git \
|
||||||
|
bison \
|
||||||
|
curl \
|
||||||
|
libxml2-dev \
|
||||||
|
php8.2-tokenizer \
|
||||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
&& 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
|
# 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
|
# Set working directory
|
||||||
WORKDIR /var/www/html
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
# Copy the application code
|
# Copy composer files first to leverage Docker cache
|
||||||
COPY . .
|
COPY composer.json composer.lock* ./
|
||||||
|
|
||||||
# Install Laravel dependencies
|
# Install Laravel dependencies
|
||||||
RUN composer install --no-dev --optimize-autoloader
|
RUN composer install --optimize-autoloader --no-dev --ignore-platform-reqs
|
||||||
|
|
||||||
# Expose port
|
# Copy the rest of the Laravel application files
|
||||||
EXPOSE 9000
|
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:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
|
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-proot"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
|
@ -29,15 +29,15 @@ services:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
volumes:
|
volumes:
|
||||||
- .:/var/www/html
|
- .:/var/www/html
|
||||||
|
- /var/www/html/vendor
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "php", "--version"]
|
test: ["CMD", "pidof", "php-fpm"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
command: >
|
start_period: 30s
|
||||||
sh -c "sleep 10 && php artisan migrate --force && php-fpm"
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
|
@ -60,4 +60,4 @@ networks:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
mysql-data:
|
mysql-data:
|
||||||
|
|
|
@ -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