Initial commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.env
|
||||||
18
LICENSE
Normal file
18
LICENSE
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2025 y9938
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
||||||
|
following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||||
|
portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||||
|
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
||||||
|
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
32
README.md
Normal file
32
README.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Laravel Docker Setup
|
||||||
|
|
||||||
|
- NGINX, MySQL, phpMyAdmin
|
||||||
|
|
||||||
|
## Создание проекта:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose run --rm php-fpm bash
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer global require laravel/installer
|
||||||
|
|
||||||
|
export PATH="$HOME/.composer/vendor/bin:$PATH"
|
||||||
|
|
||||||
|
laravel new example-app
|
||||||
|
|
||||||
|
mv example-app/* example-app/.* ./
|
||||||
|
rmdir example-app
|
||||||
|
```
|
||||||
|
|
||||||
|
Изменить `.env`
|
||||||
|
|
||||||
|
```
|
||||||
|
DB_CONNECTION=mysql
|
||||||
|
DB_HOST=mysql
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_DATABASE=app
|
||||||
|
DB_USERNAME=laravel
|
||||||
|
DB_PASSWORD=secret
|
||||||
|
DB_ROOT_PASSWORD=secret
|
||||||
|
```
|
||||||
56
compose.yaml
Normal file
56
compose.yaml
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
services:
|
||||||
|
web:
|
||||||
|
image: nginx:latest
|
||||||
|
volumes:
|
||||||
|
- ./:/var/www
|
||||||
|
- ./docker/nginx.conf:/etc/nginx/conf.d/default.conf
|
||||||
|
ports:
|
||||||
|
- "8000:80"
|
||||||
|
environment:
|
||||||
|
- NGINX_HOST=localhost
|
||||||
|
depends_on:
|
||||||
|
php-fpm:
|
||||||
|
condition: service_started
|
||||||
|
|
||||||
|
php-fpm:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: ./docker/Dockerfile
|
||||||
|
args:
|
||||||
|
UID: ${UID:-1000}
|
||||||
|
GID: ${GID:-1000}
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
- ./:/var/www
|
||||||
|
- ./docker/docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh
|
||||||
|
depends_on:
|
||||||
|
mysql:
|
||||||
|
condition: service_started
|
||||||
|
|
||||||
|
mysql:
|
||||||
|
image: mysql:8.0
|
||||||
|
ports:
|
||||||
|
- "${DB_PORT:-3306}:3306"
|
||||||
|
environment:
|
||||||
|
- MYSQL_DATABASE=${DB_DATABASE}
|
||||||
|
- MYSQL_USER=${DB_USERNAME}
|
||||||
|
- MYSQL_PASSWORD=${DB_PASSWORD}
|
||||||
|
- MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
|
||||||
|
volumes:
|
||||||
|
- mysql-data:/var/lib/mysql
|
||||||
|
|
||||||
|
phpmyadmin:
|
||||||
|
image: phpmyadmin:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "8080:80"
|
||||||
|
environment:
|
||||||
|
- PMA_HOST=mysql
|
||||||
|
- PMA_PORT=${DB_PORT:-3306}
|
||||||
|
- UPLOAD_LIMIT=100M
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
mysql-data:
|
||||||
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