Initial commit
This commit is contained in:
33
docker/Dockerfile
Normal file
33
docker/Dockerfile
Normal file
@@ -0,0 +1,33 @@
|
||||
FROM php:8.3-fpm
|
||||
|
||||
ARG UID
|
||||
ARG GID
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
netcat-traditional \
|
||||
libpng-dev \
|
||||
libonig-dev \
|
||||
libxml2-dev \
|
||||
libzip-dev \
|
||||
zip \
|
||||
unzip \
|
||||
git \
|
||||
&& docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
||||
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
COPY ./docker/php-fpm.conf /usr/local/etc/php-fpm.d/zz-docker.conf
|
||||
|
||||
COPY ./docker/docker-entrypoint.sh /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||
|
||||
RUN groupadd -g $GID laravel && useradd -u $UID -g $GID -m laravel
|
||||
USER laravel
|
||||
WORKDIR /var/www
|
||||
|
||||
EXPOSE 9000
|
||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||
CMD ["php-fpm"]
|
||||
37
docker/docker-entrypoint.sh
Executable file
37
docker/docker-entrypoint.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
cd /var/www
|
||||
|
||||
if [ -f "artisan" ]; then
|
||||
chown -R laravel:laravel /var/www/storage /var/www/bootstrap/cache
|
||||
chmod -R 775 /var/www/storage /var/www/bootstrap/cache
|
||||
|
||||
if [ ! -d "vendor" ]; then
|
||||
echo ">> Installing composer dependencies..."
|
||||
composer install --optimize-autoloader
|
||||
else
|
||||
echo ">> Vendor directory exists, skipping installation"
|
||||
fi
|
||||
|
||||
if [ -f ".env" ] && grep -q '^APP_KEY=$' .env; then
|
||||
echo ">> APP_KEY is missing. Generating application key..."
|
||||
php artisan key:generate --ansi
|
||||
fi
|
||||
|
||||
echo ">> Waiting for MySQL to be ready..."
|
||||
while ! nc -z mysql 3306; do
|
||||
sleep 1
|
||||
done
|
||||
echo ">> MySQL is ready!"
|
||||
|
||||
echo ">> Running migrations..."
|
||||
php artisan migrate --force || true
|
||||
|
||||
echo ">> Running seeders..."
|
||||
php artisan db:seed --force || true
|
||||
else
|
||||
echo ">> Not a Laravel project"
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
25
docker/nginx.conf
Normal file
25
docker/nginx.conf
Normal file
@@ -0,0 +1,25 @@
|
||||
server {
|
||||
listen 80;
|
||||
index index.php index.html;
|
||||
error_log /var/log/nginx/error.log;
|
||||
access_log /var/log/nginx/access.log;
|
||||
root /var/www/public;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass php-fpm:9000;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
12
docker/php-fpm.conf
Normal file
12
docker/php-fpm.conf
Normal file
@@ -0,0 +1,12 @@
|
||||
[global]
|
||||
daemonize = no
|
||||
|
||||
[www]
|
||||
user = laravel
|
||||
group = laravel
|
||||
listen = 9000
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 2
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
||||
Reference in New Issue
Block a user