forked from fa/breadcrumb-the-shire
chore(deploy): add production deploy config (docker-compose + nginx)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
72
deploy/docker-compose.yml
Normal file
72
deploy/docker-compose.yml
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
services:
|
||||||
|
|
||||||
|
# ── Init: копирует web/ из образа в shared volume (нужен nginx) ─────────
|
||||||
|
web_init:
|
||||||
|
image: breadcrumb-the-shire:latest
|
||||||
|
volumes:
|
||||||
|
- web_assets:/target
|
||||||
|
command: sh -c "cp -rp /var/www/web/. /target/ && echo 'Web assets OK'"
|
||||||
|
restart: "no"
|
||||||
|
|
||||||
|
# ── nginx: отдаёт статику + FastCGI → php ───────────────────────────────
|
||||||
|
nginx:
|
||||||
|
image: nginx:1.25-alpine
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:8084:80" # host nginx проксирует сюда
|
||||||
|
volumes:
|
||||||
|
- ./nginx/site.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
|
- web_assets:/var/www/web:ro
|
||||||
|
depends_on:
|
||||||
|
web_init:
|
||||||
|
condition: service_completed_successfully
|
||||||
|
php:
|
||||||
|
condition: service_started
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
# ── PHP-FPM: весь код внутри образа ─────────────────────────────────────
|
||||||
|
php:
|
||||||
|
image: breadcrumb-the-shire:latest
|
||||||
|
env_file: .env
|
||||||
|
volumes:
|
||||||
|
- ./storage:/var/www/storage
|
||||||
|
- ./var:/var/www/var
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
- memcached
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
# ── Планировщик задач ────────────────────────────────────────────────────
|
||||||
|
scheduler:
|
||||||
|
image: breadcrumb-the-shire:latest
|
||||||
|
env_file: .env
|
||||||
|
volumes:
|
||||||
|
- ./storage:/var/www/storage
|
||||||
|
- ./var:/var/www/var
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
- memcached
|
||||||
|
command: sh -c "while true; do php -d display_errors=0 bin/console scheduler:run || true; sleep 60; done"
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
# ── MariaDB ──────────────────────────────────────────────────────────────
|
||||||
|
db:
|
||||||
|
image: mariadb:11.4
|
||||||
|
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
||||||
|
env_file: .env
|
||||||
|
environment:
|
||||||
|
MARIADB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
|
||||||
|
MARIADB_DATABASE: ${DB_NAME}
|
||||||
|
MARIADB_USER: ${DB_USER}
|
||||||
|
MARIADB_PASSWORD: ${DB_PASS}
|
||||||
|
volumes:
|
||||||
|
- db_data:/var/lib/mysql
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
# ── Memcached ────────────────────────────────────────────────────────────
|
||||||
|
memcached:
|
||||||
|
image: memcached:1.6-alpine
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
web_assets: # статика из образа (web/)
|
||||||
|
db_data: # данные MariaDB
|
||||||
37
deploy/nginx/site.conf
Normal file
37
deploy/nginx/site.conf
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# Docker nginx — только HTTP (SSL терминируется на host nginx)
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name projects.breadcrumb-online.de;
|
||||||
|
|
||||||
|
client_max_body_size 10M;
|
||||||
|
|
||||||
|
root /var/www/web;
|
||||||
|
index index.php;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
# SSL терминирован на host nginx — передаём это в PHP
|
||||||
|
fastcgi_param HTTPS on;
|
||||||
|
fastcgi_param HTTP_X_FORWARDED_PROTO https;
|
||||||
|
fastcgi_pass php:9000;
|
||||||
|
fastcgi_hide_header Cache-Control;
|
||||||
|
add_header Cache-Control "no-store, no-cache, must-revalidate, private" always;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~* \.mjs$ {
|
||||||
|
default_type application/javascript;
|
||||||
|
try_files $uri =404;
|
||||||
|
expires 30d;
|
||||||
|
access_log off;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~* \.(css|js|png|jpg|jpeg|gif|svg|ico|webp|woff2?)$ {
|
||||||
|
expires 30d;
|
||||||
|
access_log off;
|
||||||
|
}
|
||||||
|
}
|
||||||
36
deploy/setup.sh
Normal file
36
deploy/setup.sh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# setup.sh — первоначальная настройка на сервере
|
||||||
|
# Запускать один раз: bash setup.sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DEPLOY_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
cd "$DEPLOY_DIR"
|
||||||
|
|
||||||
|
echo "=== [1/4] Загружаем образ в Docker ==="
|
||||||
|
docker load < breadcrumb-the-shire.tar.gz
|
||||||
|
|
||||||
|
echo "=== [2/4] Создаём папки для данных ==="
|
||||||
|
mkdir -p storage/logs storage/runtime storage/users
|
||||||
|
mkdir -p var/cache var/log var/tmp
|
||||||
|
mkdir -p nginx/certs
|
||||||
|
|
||||||
|
echo "=== [3/4] Права на папки ==="
|
||||||
|
chmod 755 storage var
|
||||||
|
chmod 775 storage/logs storage/runtime storage/users
|
||||||
|
chmod 775 var/cache var/log var/tmp
|
||||||
|
|
||||||
|
echo "=== [4/4] Готово! ==="
|
||||||
|
echo ""
|
||||||
|
echo "Следующие шаги:"
|
||||||
|
echo " 1. Получи SSL-сертификат:"
|
||||||
|
echo " certbot certonly --standalone -d projects.breadcrumb-online.de"
|
||||||
|
echo ""
|
||||||
|
echo " 2. Скопируй сертификаты:"
|
||||||
|
echo " cp /etc/letsencrypt/live/projects.breadcrumb-online.de/fullchain.pem nginx/certs/"
|
||||||
|
echo " cp /etc/letsencrypt/live/projects.breadcrumb-online.de/privkey.pem nginx/certs/"
|
||||||
|
echo ""
|
||||||
|
echo " 3. Запусти стек:"
|
||||||
|
echo " docker compose up -d"
|
||||||
|
echo ""
|
||||||
|
echo " 4. Проверь логи:"
|
||||||
|
echo " docker compose logs -f"
|
||||||
Reference in New Issue
Block a user