Fixed looping health check, composer installation, and set proper permissions
This commit is contained in:
parent
939ee01615
commit
b04d5c8e49
25
Dockerfile
25
Dockerfile
|
@ -1,5 +1,9 @@
|
||||||
|
# Use official PHP 8.2 FPM image
|
||||||
FROM php:8.2-fpm
|
FROM php:8.2-fpm
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
libpng-dev \
|
libpng-dev \
|
||||||
|
@ -9,14 +13,26 @@ RUN apt-get update && apt-get install -y \
|
||||||
zip \
|
zip \
|
||||||
unzip \
|
unzip \
|
||||||
curl \
|
curl \
|
||||||
|
git \
|
||||||
|
libonig-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
procps \
|
||||||
&& 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 gd pdo pdo_mysql
|
||||||
|
|
||||||
# Set working directory
|
# Copy the rest of Laravel files
|
||||||
WORKDIR /var/www/html
|
COPY laravel/ .
|
||||||
|
|
||||||
# Copy application
|
# Install Composer
|
||||||
COPY . .
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
|
|
||||||
|
# Copy only essential files for better build caching
|
||||||
|
COPY laravel/composer.json laravel/composer.lock ./
|
||||||
|
RUN composer install --no-dev --optimize-autoloader
|
||||||
|
|
||||||
|
# Set permissions
|
||||||
|
RUN chown -R www-data:www-data /var/www/html
|
||||||
|
RUN chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
|
||||||
|
|
||||||
# Copy entrypoint script and make it executable
|
# Copy entrypoint script and make it executable
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
@ -30,7 +46,6 @@ CMD ["php-fpm"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# FROM php:8.2-fpm
|
# FROM php:8.2-fpm
|
||||||
|
|
||||||
# RUN apt-get update && apt-get install -y \
|
# RUN apt-get update && apt-get install -y \
|
||||||
|
|
|
@ -29,7 +29,7 @@ services:
|
||||||
- DB_USERNAME=root
|
- DB_USERNAME=root
|
||||||
- DB_PASSWORD=rootpassword
|
- DB_PASSWORD=rootpassword
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost"]
|
test: ["CMD", "pgrep", "php-fpm"] # Corrected to check PHP-FPM instead of relying on Nginx
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
|
@ -50,6 +50,7 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
mysql-data:
|
mysql-data:
|
||||||
|
|
||||||
|
|
||||||
# services:
|
# services:
|
||||||
# mysql:
|
# mysql:
|
||||||
# image: mysql:latest
|
# image: mysql:latest
|
||||||
|
|
|
@ -8,6 +8,12 @@ until nc -z -v -w30 mysql 3306; do
|
||||||
done
|
done
|
||||||
echo "✅ MySQL is up and running!"
|
echo "✅ MySQL is up and running!"
|
||||||
|
|
||||||
|
# Fix ownership and permissions for storage and cache directories
|
||||||
|
echo "🔧 Setting permissions for storage and cache..."
|
||||||
|
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
|
||||||
|
echo "✅ Permissions set successfully!"
|
||||||
|
|
||||||
# Run Laravel migrations
|
# Run Laravel migrations
|
||||||
php artisan migrate --force
|
php artisan migrate --force
|
||||||
|
|
||||||
|
@ -15,7 +21,6 @@ php artisan migrate --force
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# #!/bin/bash
|
# #!/bin/bash
|
||||||
# # Fix ownership and permissions for storage directories
|
# # Fix ownership and permissions for storage directories
|
||||||
# chown -R www-data:www-data /var/www/html/storage
|
# chown -R www-data:www-data /var/www/html/storage
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit a6b9153dc1438eeb542f2bbe3f8687e9c078c0fa
|
Subproject commit 939ee016159d4f344b644a61819b6f96e66e49cb
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
index index.php index.html;
|
index index.php index.html;
|
||||||
|
@ -21,7 +22,6 @@ server {
|
||||||
add_header X-XSS-Protection "1; mode=block";
|
add_header X-XSS-Protection "1; mode=block";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# server {
|
# server {
|
||||||
# listen 80;
|
# listen 80;
|
||||||
# index index.php index.html;
|
# index index.php index.html;
|
||||||
|
|
Loading…
Reference in New Issue