first init
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
[program:historical-data-capture]
|
||||
process_name=%(program_name)s_%(process_num)02d
|
||||
command=php /var/www/artisan historical:capture
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user=www-data
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/var/www/storage/logs/historical-data-capture.log
|
||||
stopwaitsecs=3600
|
||||
stopasgroup=true
|
||||
killasgroup=true
|
||||
numprocs=1
|
||||
@@ -0,0 +1,12 @@
|
||||
[program:historical-data-scheduler]
|
||||
process_name=%(program_name)s_%(process_num)02d
|
||||
command=php /var/www/artisan schedule:work
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user=www-data
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/var/www/storage/logs/historical-data-scheduler.log
|
||||
stopwaitsecs=3600
|
||||
stopasgroup=true
|
||||
killasgroup=true
|
||||
numprocs=1
|
||||
@@ -0,0 +1,12 @@
|
||||
[program:laravel-horizon]
|
||||
process_name=%(program_name)s
|
||||
command=php /var/www/artisan horizon
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stopasgroup=true
|
||||
killasgroup=true
|
||||
user=www-data
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/var/www/storage/logs/horizon.log
|
||||
stopwaitsecs=3600
|
||||
startsecs=10
|
||||
@@ -0,0 +1,8 @@
|
||||
[program:laravel-scheduler]
|
||||
process_name=%(program_name)s
|
||||
command=bash -c "while [ true ]; do (php /var/www/artisan schedule:run --verbose --no-interaction &); sleep 60; done"
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user=www-data
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/var/www/storage/logs/scheduler.log
|
||||
@@ -0,0 +1,12 @@
|
||||
[program:laravel-worker]
|
||||
process_name=%(program_name)s_%(process_num)02d
|
||||
command=php /var/www/artisan queue:work redis --sleep=3 --tries=3 --max-time=3600
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stopasgroup=true
|
||||
killasgroup=true
|
||||
user=www-data
|
||||
numprocs=2
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/var/www/storage/logs/worker.log
|
||||
stopwaitsecs=3600
|
||||
@@ -0,0 +1,7 @@
|
||||
[program:php-fpm]
|
||||
command=php-fpm --nodaemonize
|
||||
autostart=true
|
||||
autorestart=true
|
||||
priority=5
|
||||
stdout_logfile=/var/www/storage/logs/php-fpm.log
|
||||
stderr_logfile=/var/www/storage/logs/php-fpm-error.log
|
||||
@@ -0,0 +1,18 @@
|
||||
[unix_http_server]
|
||||
file=/var/run/supervisor.sock
|
||||
chmod=0700
|
||||
|
||||
[supervisord]
|
||||
logfile=/var/www/storage/logs/supervisord.log
|
||||
pidfile=/var/run/supervisord.pid
|
||||
childlogdir=/var/www/storage/logs/
|
||||
nodaemon=true
|
||||
|
||||
[rpcinterface:supervisor]
|
||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||
|
||||
[supervisorctl]
|
||||
serverurl=unix:///var/run/supervisor.sock
|
||||
|
||||
[include]
|
||||
files = /etc/supervisor/conf.d/*.conf
|
||||
@@ -0,0 +1,175 @@
|
||||
# Stage 0: Build Vue frontend assets with Node.js
|
||||
FROM node:22 AS frontend-builder
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
# Copy frontend package files
|
||||
COPY SUTERA-frontend/package*.json ./
|
||||
COPY SUTERA-frontend/pnpm-lock.yaml* ./
|
||||
|
||||
# Install pnpm and frontend dependencies (including dev dependencies for build)
|
||||
RUN npm install -g pnpm
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Copy frontend source code
|
||||
COPY SUTERA-frontend/ ./
|
||||
|
||||
# Build TWO frontend bundles (path-based):
|
||||
# - Production: served at /
|
||||
# - Training: served at /training/
|
||||
#
|
||||
# This avoids runtime JS injection and allows training/prod UI differences
|
||||
# while keeping a single backend image.
|
||||
RUN pnpm run typecheck \
|
||||
&& pnpm exec vite build --mode=production --base=/ --outDir dist-prod \
|
||||
&& pnpm exec vite build --mode=training --base=/training/ --outDir dist-training
|
||||
|
||||
# Clean up dev dependencies to reduce image size
|
||||
ENV CI=true
|
||||
RUN pnpm prune --prod
|
||||
|
||||
# Stage 1: Build environment and Composer dependencies
|
||||
FROM php:8.4-fpm AS builder
|
||||
|
||||
LABEL maintainer="Topaz"
|
||||
|
||||
# Install system dependencies and PHP extensions for Laravel with MySQL/PostgreSQL support.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
unzip \
|
||||
libpq-dev \
|
||||
libonig-dev \
|
||||
libssl-dev \
|
||||
libxml2-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libicu-dev \
|
||||
libzip-dev \
|
||||
libjpeg-dev \
|
||||
libpng-dev \
|
||||
libfreetype6-dev \
|
||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
&& docker-php-ext-install -j$(nproc) \
|
||||
pdo_mysql \
|
||||
pdo_pgsql \
|
||||
pgsql \
|
||||
opcache \
|
||||
intl \
|
||||
zip \
|
||||
bcmath \
|
||||
soap \
|
||||
gd \
|
||||
pcntl \
|
||||
&& pecl install redis \
|
||||
&& docker-php-ext-enable redis \
|
||||
&& apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
# Set the working directory inside the container
|
||||
WORKDIR /var/www
|
||||
|
||||
# Copy the entire Laravel application code into the container
|
||||
COPY SUTERA-backend/ /var/www
|
||||
|
||||
# Copy Composer from official image (avoids flaky getcomposer.org in CI)
|
||||
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
|
||||
|
||||
# Install PHP dependencies
|
||||
RUN composer install --no-dev --optimize-autoloader --no-interaction --no-progress --prefer-dist --no-scripts \
|
||||
&& rm -rf bootstrap/cache/services.php bootstrap/cache/packages.php
|
||||
|
||||
# Stage 2: Unified production image with PHP-FPM + Nginx
|
||||
FROM php:8.4-fpm AS base
|
||||
|
||||
LABEL maintainer="Topaz"
|
||||
|
||||
# Set system timezone to Asia/Kuala_Lumpur
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends tzdata \
|
||||
&& ln -snf /usr/share/zoneinfo/Asia/Kuala_Lumpur /etc/localtime \
|
||||
&& echo "Asia/Kuala_Lumpur" > /etc/timezone \
|
||||
&& dpkg-reconfigure -f noninteractive tzdata \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
# Install Nginx and all runtime dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
nginx \
|
||||
libpq-dev \
|
||||
libicu-dev \
|
||||
libzip-dev \
|
||||
libpng-dev \
|
||||
libjpeg-dev \
|
||||
libfreetype6-dev \
|
||||
libfcgi-bin \
|
||||
procps \
|
||||
netcat-openbsd \
|
||||
supervisor \
|
||||
nano \
|
||||
curl \
|
||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
&& docker-php-ext-install gd \
|
||||
&& pecl install redis \
|
||||
&& docker-php-ext-enable redis \
|
||||
&& apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
# Download and install php-fpm health check script
|
||||
RUN curl -o /usr/local/bin/php-fpm-healthcheck \
|
||||
https://raw.githubusercontent.com/renatomefi/php-fpm-healthcheck/master/php-fpm-healthcheck \
|
||||
&& chmod +x /usr/local/bin/php-fpm-healthcheck
|
||||
|
||||
# Copy the initialization script
|
||||
COPY SUTERA-backend/docker/common/unified/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
# Copy supervisor configuration files
|
||||
COPY SUTERA-backend/docker/common/unified/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
# Create supervisor conf.d directory
|
||||
RUN mkdir -p /etc/supervisor/conf.d
|
||||
|
||||
# Use common supervisor and nginx config inside the image.
|
||||
# If you need environment-specific behavior (training vs production), override at runtime
|
||||
# by mounting files into:
|
||||
# - /etc/nginx/nginx.conf
|
||||
# - /etc/supervisor/conf.d/
|
||||
COPY SUTERA-backend/docker/common/unified/supervisor/unified.conf /etc/supervisor/conf.d/unified.conf
|
||||
COPY SUTERA-backend/docker/common/unified/nginx/nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# Copy the initial storage structure
|
||||
COPY SUTERA-backend/storage /var/www/storage-init
|
||||
|
||||
# Copy PHP extensions and libraries from the builder stage
|
||||
COPY --from=builder /usr/local/lib/php/extensions/ /usr/local/lib/php/extensions/
|
||||
COPY --from=builder /usr/local/etc/php/conf.d/ /usr/local/etc/php/conf.d/
|
||||
COPY --from=builder /usr/local/bin/docker-php-ext-* /usr/local/bin/
|
||||
|
||||
# Use the recommended production PHP configuration
|
||||
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
|
||||
|
||||
# Enable PHP-FPM status page via separate config file (avoid modifying zz-docker.conf)
|
||||
RUN echo '[www]' > /usr/local/etc/php-fpm.d/zzz-status.conf && \
|
||||
echo 'pm.status_path = /status' >> /usr/local/etc/php-fpm.d/zzz-status.conf
|
||||
|
||||
# Copy the application code and dependencies from the build stage first
|
||||
COPY --from=builder /var/www /var/www
|
||||
|
||||
# Copy the built Vue frontends from frontend-builder stage
|
||||
# - Production frontend at /
|
||||
COPY --from=frontend-builder /app/frontend/dist-prod /var/www/public/
|
||||
# - Training frontend at /training/
|
||||
COPY --from=frontend-builder /app/frontend/dist-training /var/www/public/training/
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /var/www
|
||||
|
||||
# Ensure correct permissions
|
||||
RUN chown -R www-data:www-data /var/www
|
||||
|
||||
# Create Nginx log directory
|
||||
RUN mkdir -p /var/log/nginx && chown -R www-data:www-data /var/log/nginx
|
||||
|
||||
# Run the entrypoint script
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
|
||||
# Expose port 80 (Nginx) and 9000 (PHP-FPM for health checks)
|
||||
EXPOSE 80 9000
|
||||
|
||||
# Start supervisor which manages both Nginx and PHP-FPM
|
||||
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
echo "Starting Laravel entrypoint (Unified)..."
|
||||
|
||||
# Step 0: Wait for DB if configured
|
||||
if [ -n "${DB_HOST:-}" ]; then
|
||||
echo "Waiting for DB at ${DB_HOST}:${DB_PORT:-5432}..."
|
||||
# Wait up to ~60s (60 * 1s)
|
||||
i=0
|
||||
while ! nc -z "$DB_HOST" "${DB_PORT:-5432}"; do
|
||||
i=$((i + 1))
|
||||
if [ "$i" -ge 60 ]; then
|
||||
echo "DB not reachable after 60s. Continuing anyway."
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "DB check finished."
|
||||
fi
|
||||
|
||||
# Step 1: Initialize persistent storage if needed
|
||||
if [ ! "$(ls -A /var/www/storage 2>/dev/null)" ]; then
|
||||
echo "Initializing /var/www/storage..."
|
||||
cp -R /var/www/storage-init/. /var/www/storage
|
||||
chown -R www-data:www-data /var/www/storage
|
||||
else
|
||||
echo "/var/www/storage already initialized."
|
||||
fi
|
||||
|
||||
rm -rf /var/www/storage-init
|
||||
|
||||
# Step 2: Ensure environment is ready
|
||||
if [ ! -f .env ]; then
|
||||
echo ".env file is missing!"
|
||||
echo "Provide it at runtime (bind mount, env_file, or secret) to /var/www/.env."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure bootstrap/cache directory exists and writable BEFORE artisan
|
||||
if [ ! -d bootstrap/cache ]; then
|
||||
echo "Creating bootstrap/cache directory..."
|
||||
mkdir -p bootstrap/cache
|
||||
fi
|
||||
chown -R www-data:www-data bootstrap/cache
|
||||
|
||||
# Step 3: Laravel setup and optimization
|
||||
php artisan storage:link || true
|
||||
php artisan config:clear
|
||||
php artisan config:cache
|
||||
php artisan route:cache
|
||||
php artisan event:cache
|
||||
php artisan package:discover --ansi
|
||||
|
||||
# Step 4: Set permissions
|
||||
chown -R www-data:www-data /var/www/storage
|
||||
chown -R www-data:www-data /var/www/bootstrap/cache
|
||||
|
||||
# Step 5: Ensure Laravel log directory exists
|
||||
mkdir -p /var/www/storage/logs
|
||||
chown -R www-data:www-data /var/www/storage/logs
|
||||
|
||||
# Step 6: Create supervisor log directories
|
||||
mkdir -p /var/log/supervisor
|
||||
chown -R root:root /var/log/supervisor
|
||||
|
||||
echo "Laravel setup complete. Starting Supervisor..."
|
||||
exec supervisord -c /etc/supervisor/supervisord.conf
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
# Logging
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
# HTTP server (default - works for training/dev)
|
||||
# For production with HTTPS, mount a custom nginx.conf that includes SSL config
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
root /var/www/public;
|
||||
index index.php index.html;
|
||||
|
||||
# Security headers
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
||||
|
||||
# API routes - pass directly to Laravel with original REQUEST_URI
|
||||
# (try_files would redirect to /index.php and lose the path, causing 502/bad routing)
|
||||
location /api/ {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
fastcgi_param HTTPS $https if_not_empty;
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
}
|
||||
|
||||
# Training SPA (built with base=/training/)
|
||||
# Serve training frontend routes from /var/www/public/training
|
||||
location ^~ /training/ {
|
||||
try_files $uri $uri/ /training/index.html;
|
||||
}
|
||||
|
||||
# Serve frontend assets
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# Handle all other routes - serve Vue app or Laravel
|
||||
location / {
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
|
||||
try_files $uri $uri/ /index.html /index.php?$query_string;
|
||||
}
|
||||
|
||||
# Handle PHP files - connect to localhost PHP-FPM
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
|
||||
# Additional FastCGI parameters
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
fastcgi_param HTTPS $https if_not_empty;
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
}
|
||||
|
||||
# Deny access to hidden files
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
}
|
||||
|
||||
# Cache static assets
|
||||
location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
location ^~ /horizon {
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob 'unsafe-inline' 'unsafe-eval'" always;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
fastcgi_param HTTPS $https if_not_empty;
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
}
|
||||
}
|
||||
|
||||
# HTTPS server block removed from default config
|
||||
# To enable HTTPS in production:
|
||||
# 1. Mount SSL certificates to /etc/nginx/ssl/
|
||||
# 2. Mount a custom nginx.conf that includes HTTPS server block
|
||||
# Example: - ./production-nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
port 6379
|
||||
bind 0.0.0.0
|
||||
requirepass sutera_redis@2025
|
||||
@@ -0,0 +1,19 @@
|
||||
[unix_http_server]
|
||||
file=/var/run/supervisor.sock
|
||||
chmod=0700
|
||||
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
logfile=/var/log/supervisor/supervisord.log
|
||||
pidfile=/var/run/supervisord.pid
|
||||
childlogdir=/var/log/supervisor
|
||||
user=root
|
||||
|
||||
[rpcinterface:supervisor]
|
||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||
|
||||
[supervisorctl]
|
||||
serverurl=unix:///var/run/supervisor.sock
|
||||
|
||||
[include]
|
||||
files = /etc/supervisor/conf.d/*.conf
|
||||
@@ -0,0 +1,48 @@
|
||||
[program:php-fpm]
|
||||
command=php-fpm -F
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stderr_logfile=/var/log/supervisor/php-fpm.err.log
|
||||
stdout_logfile=/var/log/supervisor/php-fpm.out.log
|
||||
user=root
|
||||
priority=100
|
||||
|
||||
[program:nginx]
|
||||
command=nginx -g "daemon off;"
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stderr_logfile=/var/log/supervisor/nginx.err.log
|
||||
stdout_logfile=/var/log/supervisor/nginx.out.log
|
||||
user=root
|
||||
priority=200
|
||||
|
||||
[program:laravel-horizon]
|
||||
process_name=%(program_name)s_%(process_num)02d
|
||||
command=php /var/www/artisan horizon
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user=www-data
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/var/www/storage/logs/horizon.log
|
||||
stopwaitsecs=3600
|
||||
priority=300
|
||||
|
||||
[program:laravel-worker]
|
||||
process_name=%(program_name)s_%(process_num)02d
|
||||
command=php /var/www/artisan queue:work redis --sleep=3 --tries=3 --max-time=3600
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user=www-data
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/var/www/storage/logs/worker.log
|
||||
stopwaitsecs=3600
|
||||
priority=400
|
||||
|
||||
[program:laravel-scheduler]
|
||||
command=php /var/www/artisan schedule:work
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user=www-data
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/var/www/storage/logs/scheduler.log
|
||||
priority=500
|
||||
@@ -0,0 +1,77 @@
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./SUTERA-backend/docker/common/unified/Dockerfile
|
||||
platforms:
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
image: git.ismailmasseran.com/topaz/sutera:v3.0.1b
|
||||
container_name: sutera-app-production
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${APP_PORT:-80}:80"
|
||||
environment:
|
||||
- APP_ENV=production
|
||||
- APP_DEBUG=true
|
||||
- REDIS_HOST=redis
|
||||
- REDIS_PASSWORD=${REDIS_PASSWORD}
|
||||
- CACHE_DRIVER=redis
|
||||
- SESSION_DRIVER=redis
|
||||
- QUEUE_CONNECTION=redis
|
||||
volumes:
|
||||
- app-storage-production:/var/www/storage
|
||||
- app-logs-production:/var/www/storage/logs
|
||||
- ./.env.production:/var/www/.env:ro
|
||||
- ./SUTERA-backend/docker/production/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
networks:
|
||||
- sutera-production-network
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
# Redis for caching and sessions
|
||||
redis:
|
||||
image: redis:8
|
||||
container_name: sutera-redis-production
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- redis-data-production:/data
|
||||
- ./redis-config/redis.conf:/usr/local/etc/redis/redis.conf:ro
|
||||
command: redis-server /usr/local/etc/redis/redis.conf
|
||||
networks:
|
||||
- sutera-production-network
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
networks:
|
||||
sutera-production-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
app-storage-production:
|
||||
driver: local
|
||||
app-logs-production:
|
||||
driver: local
|
||||
redis-data-production:
|
||||
driver: local
|
||||
@@ -0,0 +1,100 @@
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
# Logging
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
# Production HTTP server
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
root /var/www/public;
|
||||
index index.php index.html;
|
||||
|
||||
# Security headers
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
||||
|
||||
# API routes - pass directly to Laravel with original REQUEST_URI
|
||||
location / {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
fastcgi_param HTTPS $https if_not_empty;
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
}
|
||||
|
||||
# PRODUCTION: /training/ path is disabled - return 404
|
||||
location ^~ /training/ {
|
||||
return 404;
|
||||
}
|
||||
|
||||
# Serve frontend assets
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# Handle all other routes - serve Vue app or Laravel
|
||||
location / {
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
|
||||
try_files $uri $uri/ /index.html /index.php?$query_string;
|
||||
}
|
||||
|
||||
# Handle PHP files - connect to localhost PHP-FPM
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
|
||||
# Additional FastCGI parameters
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
fastcgi_param HTTPS $https if_not_empty;
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
}
|
||||
|
||||
# Deny access to hidden files
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
}
|
||||
|
||||
# Health check endpoint for Docker
|
||||
location = /health {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
}
|
||||
|
||||
location ^~ /horizon {
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob 'unsafe-inline' 'unsafe-eval'" always;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
fastcgi_param HTTPS $https if_not_empty;
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
port 6379
|
||||
bind 0.0.0.0
|
||||
requirepass sutera_redis@2025
|
||||
@@ -0,0 +1,117 @@
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./SUTERA-backend/docker/common/unified/Dockerfile
|
||||
args:
|
||||
ENV: staging
|
||||
platforms:
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
image: sutera-app-staging:latest
|
||||
container_name: sutera-app-staging
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${APP_PORT:-80}:80"
|
||||
- "${HTTPS_PORT:-443}:443"
|
||||
environment:
|
||||
- APP_ENV=staging
|
||||
- APP_DEBUG=true
|
||||
- DB_HOST=postgres
|
||||
- DB_PORT=${DB_PORT:-5432}
|
||||
- DB_DATABASE=${DB_DATABASE}
|
||||
- DB_USERNAME=${DB_USERNAME}
|
||||
- DB_PASSWORD=${DB_PASSWORD}
|
||||
- REDIS_HOST=redis
|
||||
- REDIS_PASSWORD=${REDIS_PASSWORD}
|
||||
- CACHE_DRIVER=redis
|
||||
- SESSION_DRIVER=redis
|
||||
- QUEUE_CONNECTION=redis
|
||||
volumes:
|
||||
- app-storage-staging:/var/www/storage
|
||||
- app-logs-staging:/var/www/storage/logs
|
||||
- /etc/letsencrypt/live/sutera.ismailmasseran.com/fullchain.pem:/etc/nginx/ssl/fullchain.pem:ro
|
||||
- /etc/letsencrypt/live/sutera.ismailmasseran.com/privkey.pem:/etc/nginx/ssl/privkey.pem:ro
|
||||
networks:
|
||||
- sutera-staging-network
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
# Redis for caching and sessions
|
||||
redis:
|
||||
image: redis:8.2-alpine
|
||||
container_name: sutera-redis-staging
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- redis-data-staging:/data
|
||||
- ./redis-config/redis.conf:/usr/local/etc/redis/redis.conf:ro
|
||||
command: redis-server /usr/local/etc/redis/redis.conf
|
||||
networks:
|
||||
- sutera-staging-network
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
# Optional: Database (only if you want to run DB on same server for staging)
|
||||
# Uncomment if you want to run MySQL on the same server for staging
|
||||
postgres:
|
||||
image: postgres:17
|
||||
container_name: sutera-postgres-staging
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${DB_PORT:-5432}:5432"
|
||||
environment:
|
||||
- POSTGRES_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
|
||||
- POSTGRES_DATABASE=${DB_DATABASE}
|
||||
- POSTGRES_USER=${DB_USERNAME}
|
||||
- POSTGRES_PASSWORD=${DB_PASSWORD}
|
||||
volumes:
|
||||
- postgres-data-staging:/var/lib/postgres
|
||||
- ./SUTERA-backend/docker/postgres/conf.d:/etc/postgres/conf.d:ro
|
||||
networks:
|
||||
- sutera-staging-network
|
||||
healthcheck:
|
||||
test: ["CMD", "postgres", "ping", "-h", "localhost"]
|
||||
interval: 15s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
start_period: 30s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
networks:
|
||||
sutera-staging-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
app-storage-staging:
|
||||
driver: local
|
||||
app-logs-staging:
|
||||
driver: local
|
||||
redis-data-staging:
|
||||
driver: local
|
||||
postgres-data-staging:
|
||||
driver: local
|
||||
@@ -0,0 +1,100 @@
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
# Logging
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
# Production HTTP server
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
root /var/www/public;
|
||||
index index.php index.html;
|
||||
|
||||
# Security headers
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
||||
|
||||
# API routes - pass directly to Laravel with original REQUEST_URI
|
||||
location /api/ {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
fastcgi_param HTTPS $https if_not_empty;
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
}
|
||||
|
||||
# PRODUCTION: /training/ path is disabled - return 404
|
||||
location ^~ /training/ {
|
||||
return 404;
|
||||
}
|
||||
|
||||
# Serve frontend assets
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# Handle all other routes - serve Vue app or Laravel
|
||||
location / {
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
|
||||
try_files $uri $uri/ /index.html /index.php?$query_string;
|
||||
}
|
||||
|
||||
# Handle PHP files - connect to localhost PHP-FPM
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
|
||||
# Additional FastCGI parameters
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
fastcgi_param HTTPS $https if_not_empty;
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
}
|
||||
|
||||
# Deny access to hidden files
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
}
|
||||
|
||||
# Health check endpoint for Docker
|
||||
location = /health {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
}
|
||||
|
||||
location ^~ /horizon {
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob 'unsafe-inline' 'unsafe-eval'" always;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
fastcgi_param HTTPS $https if_not_empty;
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
port 6379
|
||||
bind 0.0.0.0
|
||||
requirepass sutera_redis@2025
|
||||
@@ -0,0 +1,114 @@
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./SUTERA-backend/docker/common/unified/Dockerfile
|
||||
platforms:
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
image: git.ismailmasseran.com/topaz/sutera:33a53e08a641152f255f5c3fa27765200add4f45
|
||||
container_name: sutera-app-training
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${APP_PORT:-80}:80"
|
||||
environment:
|
||||
- APP_ENV=training
|
||||
- APP_DEBUG=true
|
||||
- DB_HOST=postgres
|
||||
- DB_PORT=${DB_PORT:-5432}
|
||||
- DB_DATABASE=${DB_DATABASE}
|
||||
- DB_USERNAME=${DB_USERNAME}
|
||||
- DB_PASSWORD=${DB_PASSWORD}
|
||||
- REDIS_HOST=redis
|
||||
- REDIS_PASSWORD=${REDIS_PASSWORD}
|
||||
- CACHE_DRIVER=redis
|
||||
- SESSION_DRIVER=redis
|
||||
- QUEUE_CONNECTION=redis
|
||||
volumes:
|
||||
- app-storage-training:/var/www/storage
|
||||
- app-logs-training:/var/www/storage/logs
|
||||
- ./.env.training:/var/www/.env:ro
|
||||
- ./SUTERA-backend/docker/training/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
networks:
|
||||
- sutera-training-network
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
# Redis for caching and sessions
|
||||
redis:
|
||||
image: redis:8
|
||||
container_name: sutera-redis-training
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- redis-data-training:/data
|
||||
- ./redis-config/redis.conf:/usr/local/etc/redis/redis.conf:ro
|
||||
command: redis-server /usr/local/etc/redis/redis.conf
|
||||
networks:
|
||||
- sutera-training-network
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
# Optional: Database (only if you want to run DB on same server for training)
|
||||
# Uncomment if you want to run MySQL on the same server for training
|
||||
postgres:
|
||||
image: postgres:17
|
||||
container_name: sutera-postgres-training
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${DB_PORT:-5432}:5432"
|
||||
environment:
|
||||
- POSTGRES_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
|
||||
- POSTGRES_DATABASE=${DB_DATABASE}
|
||||
- POSTGRES_USER=${DB_USERNAME}
|
||||
- POSTGRES_PASSWORD=${DB_PASSWORD}
|
||||
volumes:
|
||||
- postgres-data-training:/var/lib/postgres
|
||||
- ./SUTERA-backend/docker/postgres/conf.d:/etc/postgres/conf.d:ro
|
||||
networks:
|
||||
- sutera-training-network
|
||||
healthcheck:
|
||||
test: ["CMD", "postgres", "ping", "-h", "localhost"]
|
||||
interval: 15s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
start_period: 30s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
networks:
|
||||
sutera-training-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
app-storage-training:
|
||||
driver: local
|
||||
app-logs-training:
|
||||
driver: local
|
||||
redis-data-training:
|
||||
driver: local
|
||||
postgres-data-training:
|
||||
driver: local
|
||||
@@ -0,0 +1,106 @@
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
# Logging
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
# Training HTTP server
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
root /var/www/public;
|
||||
index index.php index.html;
|
||||
|
||||
# Security headers
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
||||
|
||||
# API routes - pass directly to Laravel with original REQUEST_URI
|
||||
location /api/ {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
fastcgi_param HTTPS $https if_not_empty;
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
}
|
||||
|
||||
# Training SPA (built with base=/training/)
|
||||
# Serve training frontend routes from /var/www/public/training
|
||||
location ^~ /training/ {
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
|
||||
try_files $uri $uri/ /training/index.html;
|
||||
}
|
||||
|
||||
# Serve assets under /training/assets/
|
||||
location ~* ^/training/.*\.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# Handle PHP files - connect to localhost PHP-FPM
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
|
||||
# Additional FastCGI parameters
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
fastcgi_param HTTPS $https if_not_empty;
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
}
|
||||
|
||||
# Deny access to hidden files
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
}
|
||||
|
||||
# Health check endpoint for Docker
|
||||
location = /health {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
}
|
||||
|
||||
location ^~ /horizon {
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob 'unsafe-inline' 'unsafe-eval'" always;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
fastcgi_param HTTPS $https if_not_empty;
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
}
|
||||
|
||||
# TRAINING: Root path disabled - redirect to /training/
|
||||
location = / {
|
||||
return 302 /training/;
|
||||
}
|
||||
|
||||
# TRAINING: All other paths return 404 (production frontend disabled)
|
||||
location / {
|
||||
return 404;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
port 6379
|
||||
bind 0.0.0.0
|
||||
requirepass sutera_redis@2025
|
||||
Reference in New Issue
Block a user