Security cleanup: remove Docker files, test pages, SQL backup; fix admin password
This commit is contained in:
34
Dockerfile
34
Dockerfile
@@ -1,34 +0,0 @@
|
|||||||
FROM php:8.1-apache
|
|
||||||
|
|
||||||
# Install required packages
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
msmtp \
|
|
||||||
msmtp-mta \
|
|
||||||
mailutils \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Enable Apache modules
|
|
||||||
RUN a2enmod rewrite headers
|
|
||||||
|
|
||||||
# Set ServerName to avoid warnings
|
|
||||||
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
|
|
||||||
|
|
||||||
# Configure Apache for our application
|
|
||||||
COPY apache-config.conf /etc/apache2/sites-available/000-default.conf
|
|
||||||
|
|
||||||
# Copy application files
|
|
||||||
COPY . /var/www/html/
|
|
||||||
|
|
||||||
# Configure msmtp
|
|
||||||
COPY .msmtprc /etc/msmtprc
|
|
||||||
RUN chmod 600 /etc/msmtprc
|
|
||||||
RUN echo "sendmail_path = /usr/bin/msmtp -t" > /usr/local/etc/php/conf.d/mail.ini
|
|
||||||
|
|
||||||
# Set proper permissions
|
|
||||||
RUN chown -R www-data:www-data /var/www/html
|
|
||||||
RUN chmod -R 755 /var/www/html
|
|
||||||
|
|
||||||
# Create logs directory
|
|
||||||
RUN mkdir -p /var/www/html/logs && chown www-data:www-data /var/www/html/logs
|
|
||||||
|
|
||||||
EXPOSE 80
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
# UK Data Services - Optimized Production Dockerfile
|
|
||||||
FROM php:8.1-apache
|
|
||||||
|
|
||||||
# Metadata
|
|
||||||
LABEL maintainer="UK Data Services <dev@ukdataservices.co.uk>"
|
|
||||||
LABEL description="UK Data Services website - Professional data solutions"
|
|
||||||
LABEL version="1.0.0"
|
|
||||||
|
|
||||||
# Install system dependencies and PHP extensions
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
libpng-dev \
|
|
||||||
libjpeg-dev \
|
|
||||||
libfreetype6-dev \
|
|
||||||
libzip-dev \
|
|
||||||
libxml2-dev \
|
|
||||||
libcurl4-openssl-dev \
|
|
||||||
unzip \
|
|
||||||
wget \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Configure and install PHP extensions
|
|
||||||
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
|
|
||||||
&& docker-php-ext-install -j$(nproc) \
|
|
||||||
gd \
|
|
||||||
mysqli \
|
|
||||||
pdo \
|
|
||||||
pdo_mysql \
|
|
||||||
zip \
|
|
||||||
xml \
|
|
||||||
curl \
|
|
||||||
json
|
|
||||||
|
|
||||||
# Enable Apache modules for production
|
|
||||||
RUN a2enmod rewrite headers expires deflate ssl
|
|
||||||
|
|
||||||
# Configure Apache for security and performance
|
|
||||||
RUN echo "ServerName ukdataservices.local" >> /etc/apache2/apache2.conf
|
|
||||||
RUN echo "ServerTokens Prod" >> /etc/apache2/apache2.conf
|
|
||||||
RUN echo "ServerSignature Off" >> /etc/apache2/apache2.conf
|
|
||||||
|
|
||||||
# Copy Apache configuration
|
|
||||||
COPY docker/apache-config.conf /etc/apache2/sites-available/000-default.conf
|
|
||||||
|
|
||||||
# Copy PHP configuration
|
|
||||||
COPY docker/php.ini /usr/local/etc/php/conf.d/custom.ini
|
|
||||||
|
|
||||||
# Create application directories
|
|
||||||
RUN mkdir -p /var/www/html/logs \
|
|
||||||
&& mkdir -p /var/www/html/uploads \
|
|
||||||
&& mkdir -p /var/www/html/cache
|
|
||||||
|
|
||||||
# Copy application files (excluding development files)
|
|
||||||
COPY --chown=www-data:www-data . /var/www/html/
|
|
||||||
|
|
||||||
# Remove development and Git files from production image
|
|
||||||
RUN rm -rf /var/www/html/.git* \
|
|
||||||
&& rm -rf /var/www/html/PROJECT-MEMORY-REPORT.md \
|
|
||||||
&& rm -rf /var/www/html/SITE-ERROR-ANALYSIS.md \
|
|
||||||
&& rm -rf /var/www/html/docker* \
|
|
||||||
&& rm -rf /var/www/html/README.md
|
|
||||||
|
|
||||||
# Set correct permissions
|
|
||||||
RUN chown -R www-data:www-data /var/www/html \
|
|
||||||
&& find /var/www/html -type d -exec chmod 755 {} \; \
|
|
||||||
&& find /var/www/html -type f -exec chmod 644 {} \; \
|
|
||||||
&& chmod 755 /var/www/html/logs \
|
|
||||||
&& chmod 755 /var/www/html/uploads \
|
|
||||||
&& chmod 755 /var/www/html/cache
|
|
||||||
|
|
||||||
# Copy and set up the enhanced .htaccess
|
|
||||||
RUN cp /var/www/html/.htaccess-advanced /var/www/html/.htaccess
|
|
||||||
|
|
||||||
# Health check
|
|
||||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
||||||
CMD curl -f http://localhost/ || exit 1
|
|
||||||
|
|
||||||
# Security: Create non-root user for runtime (if needed)
|
|
||||||
RUN groupadd -r appgroup && useradd -r -g appgroup appuser
|
|
||||||
|
|
||||||
# Expose ports
|
|
||||||
EXPOSE 80
|
|
||||||
EXPOSE 443
|
|
||||||
|
|
||||||
# Set working directory
|
|
||||||
WORKDIR /var/www/html
|
|
||||||
|
|
||||||
# Start Apache in foreground
|
|
||||||
CMD ["apache2-ctl", "-D", "FOREGROUND"]
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
// Basic authentication - REPLACE WITH PROPER AUTH IN PRODUCTION
|
// Basic authentication - REPLACE WITH PROPER AUTH IN PRODUCTION
|
||||||
$AUTH_PASSWORD = 'admin123'; // Change this!
|
$AUTH_PASSWORD = '6JASrjTkN77yyHslZhku6pDv'; // Change this!
|
||||||
|
|
||||||
if (!isset($_SESSION['authenticated']) || $_SESSION['authenticated'] !== true) {
|
if (!isset($_SESSION['authenticated']) || $_SESSION['authenticated'] !== true) {
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['password'])) {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['password'])) {
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Button Test</title>
|
|
||||||
<link rel="stylesheet" href="assets/css/main.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div style="padding: 50px;">
|
|
||||||
<h1>Button Test Page</h1>
|
|
||||||
|
|
||||||
<h2>Button Tests:</h2>
|
|
||||||
<p>Primary button: <a href="#" class="btn btn-primary">Get ROI Assessment</a></p>
|
|
||||||
<p>Secondary button: <a href="#" class="btn btn-secondary">Learn More</a></p>
|
|
||||||
|
|
||||||
<div class="expert-consultation-cta">
|
|
||||||
<h3>Ready to Measure Your CI ROI?</h3>
|
|
||||||
<p>Our analytics team can help you implement comprehensive ROI measurement frameworks tailored to your industry and business model.</p>
|
|
||||||
<a href="#" class="btn btn-primary">Get ROI Assessment</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2>Debug Info:</h2>
|
|
||||||
<p>If you can see this text, CSS is loading properly.</p>
|
|
||||||
<p>Check if buttons above have text and green background.</p>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Core Web Vitals Monitor | UK Data Services</title>
|
|
||||||
<meta name="robots" content="noindex, nofollow">
|
|
||||||
<style>
|
|
||||||
body { font-family: Arial, sans-serif; margin: 20px; background: #f5f5f5; }
|
|
||||||
.monitor { background: white; padding: 20px; border-radius: 8px; margin-bottom: 20px; }
|
|
||||||
.metric { display: flex; justify-content: space-between; margin: 10px 0; }
|
|
||||||
.value { font-weight: bold; }
|
|
||||||
.good { color: #0f5132; }
|
|
||||||
.poor { color: #842029; }
|
|
||||||
.needs-improvement { color: #664d03; }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Core Web Vitals Monitor</h1>
|
|
||||||
|
|
||||||
<div class="monitor">
|
|
||||||
<h2>Current Page Performance</h2>
|
|
||||||
<div id="metrics">
|
|
||||||
<div class="metric">
|
|
||||||
<span>Largest Contentful Paint (LCP):</span>
|
|
||||||
<span class="value" id="lcp">Measuring...</span>
|
|
||||||
</div>
|
|
||||||
<div class="metric">
|
|
||||||
<span>First Input Delay (FID):</span>
|
|
||||||
<span class="value" id="fid">Measuring...</span>
|
|
||||||
</div>
|
|
||||||
<div class="metric">
|
|
||||||
<span>Cumulative Layout Shift (CLS):</span>
|
|
||||||
<span class="value" id="cls">Measuring...</span>
|
|
||||||
</div>
|
|
||||||
<div class="metric">
|
|
||||||
<span>First Contentful Paint (FCP):</span>
|
|
||||||
<span class="value" id="fcp">Measuring...</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="monitor">
|
|
||||||
<h2>Performance Recommendations</h2>
|
|
||||||
<ul id="recommendations">
|
|
||||||
<li>Loading performance metrics...</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
// Core Web Vitals monitoring implementation
|
|
||||||
function getScoreClass(metric, value) {
|
|
||||||
const thresholds = {
|
|
||||||
lcp: { good: 2500, poor: 4000 },
|
|
||||||
fid: { good: 100, poor: 300 },
|
|
||||||
cls: { good: 0.1, poor: 0.25 },
|
|
||||||
fcp: { good: 1800, poor: 3000 }
|
|
||||||
};
|
|
||||||
|
|
||||||
if (value <= thresholds[metric].good) return 'good';
|
|
||||||
if (value <= thresholds[metric].poor) return 'needs-improvement';
|
|
||||||
return 'poor';
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateMetric(name, value, unit = 'ms') {
|
|
||||||
const element = document.getElementById(name);
|
|
||||||
const displayValue = unit === 'ms' ? Math.round(value) : value.toFixed(3);
|
|
||||||
element.textContent = `${displayValue}${unit}`;
|
|
||||||
element.className = `value ${getScoreClass(name, value)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Measure Core Web Vitals using web-vitals library approach
|
|
||||||
function measureCoreWebVitals() {
|
|
||||||
// LCP - Largest Contentful Paint
|
|
||||||
new PerformanceObserver((entryList) => {
|
|
||||||
const entries = entryList.getEntries();
|
|
||||||
const lastEntry = entries[entries.length - 1];
|
|
||||||
updateMetric('lcp', lastEntry.startTime);
|
|
||||||
}).observe({ entryTypes: ['largest-contentful-paint'] });
|
|
||||||
|
|
||||||
// FID - First Input Delay
|
|
||||||
new PerformanceObserver((entryList) => {
|
|
||||||
const firstEntry = entryList.getEntries()[0];
|
|
||||||
updateMetric('fid', firstEntry.processingStart - firstEntry.startTime);
|
|
||||||
}).observe({ entryTypes: ['first-input'] });
|
|
||||||
|
|
||||||
// CLS - Cumulative Layout Shift
|
|
||||||
let clsValue = 0;
|
|
||||||
new PerformanceObserver((entryList) => {
|
|
||||||
for (const entry of entryList.getEntries()) {
|
|
||||||
if (!entry.hadRecentInput) {
|
|
||||||
clsValue += entry.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateMetric('cls', clsValue, '');
|
|
||||||
}).observe({ entryTypes: ['layout-shift'] });
|
|
||||||
|
|
||||||
// FCP - First Contentful Paint
|
|
||||||
new PerformanceObserver((entryList) => {
|
|
||||||
const entries = entryList.getEntries();
|
|
||||||
const fcpEntry = entries.find(entry => entry.name === 'first-contentful-paint');
|
|
||||||
if (fcpEntry) {
|
|
||||||
updateMetric('fcp', fcpEntry.startTime);
|
|
||||||
}
|
|
||||||
}).observe({ entryTypes: ['paint'] });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate recommendations based on performance
|
|
||||||
function generateRecommendations() {
|
|
||||||
const recommendations = [
|
|
||||||
"✅ Images are optimized with WebP format and lazy loading",
|
|
||||||
"✅ CSS and JavaScript are minified",
|
|
||||||
"✅ Critical resources are preloaded",
|
|
||||||
"✅ Service worker implemented for caching",
|
|
||||||
"⚡ Consider implementing resource hints for external domains",
|
|
||||||
"⚡ Monitor server response times for optimal TTFB",
|
|
||||||
"⚡ Consider implementing HTTP/2 push for critical resources"
|
|
||||||
];
|
|
||||||
|
|
||||||
document.getElementById('recommendations').innerHTML =
|
|
||||||
recommendations.map(rec => `<li>${rec}</li>`).join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize monitoring
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
|
||||||
measureCoreWebVitals();
|
|
||||||
generateRecommendations();
|
|
||||||
|
|
||||||
// Report to analytics (example implementation)
|
|
||||||
setTimeout(() => {
|
|
||||||
console.log('Core Web Vitals data collected for analysis');
|
|
||||||
}, 3000);
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,95 +0,0 @@
|
|||||||
# UK Data Services - Development Docker Compose
|
|
||||||
# Simplified setup for local development and testing
|
|
||||||
|
|
||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
|
||||||
# Web Application (Development)
|
|
||||||
web:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
container_name: ukds-dev-web
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "8080:80"
|
|
||||||
volumes:
|
|
||||||
# Live code editing
|
|
||||||
- .:/var/www/html
|
|
||||||
# Persistent logs
|
|
||||||
- ./logs:/var/www/html/logs
|
|
||||||
environment:
|
|
||||||
- APACHE_DOCUMENT_ROOT=/var/www/html
|
|
||||||
- PHP_DISPLAY_ERRORS=On
|
|
||||||
- PHP_ERROR_REPORTING=E_ALL
|
|
||||||
# Database connection
|
|
||||||
- DB_HOST=database
|
|
||||||
- DB_NAME=ukdataservices_dev
|
|
||||||
- DB_USER=devuser
|
|
||||||
- DB_PASSWORD=devpassword
|
|
||||||
# Development settings
|
|
||||||
- SITE_URL=http://localhost:8080
|
|
||||||
- CONTACT_EMAIL=dev@ukdataservices.co.uk
|
|
||||||
- DEBUG_MODE=1
|
|
||||||
depends_on:
|
|
||||||
- database
|
|
||||||
networks:
|
|
||||||
- ukds-dev-network
|
|
||||||
|
|
||||||
# Database (Development)
|
|
||||||
database:
|
|
||||||
image: mysql:8.0
|
|
||||||
container_name: ukds-dev-database
|
|
||||||
restart: unless-stopped
|
|
||||||
environment:
|
|
||||||
MYSQL_ROOT_PASSWORD: rootpassword
|
|
||||||
MYSQL_DATABASE: ukdataservices_dev
|
|
||||||
MYSQL_USER: devuser
|
|
||||||
MYSQL_PASSWORD: devpassword
|
|
||||||
ports:
|
|
||||||
- "3307:3306"
|
|
||||||
volumes:
|
|
||||||
# Development database (not persistent)
|
|
||||||
- dev_mysql_data:/var/lib/mysql
|
|
||||||
# Database initialization
|
|
||||||
- ./database/init:/docker-entrypoint-initdb.d:ro
|
|
||||||
networks:
|
|
||||||
- ukds-dev-network
|
|
||||||
|
|
||||||
# phpMyAdmin (Development only)
|
|
||||||
phpmyadmin:
|
|
||||||
image: phpmyadmin/phpmyadmin:latest
|
|
||||||
container_name: ukds-dev-phpmyadmin
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "8081:80"
|
|
||||||
environment:
|
|
||||||
PMA_HOST: database
|
|
||||||
PMA_USER: devuser
|
|
||||||
PMA_PASSWORD: devpassword
|
|
||||||
MYSQL_ROOT_PASSWORD: rootpassword
|
|
||||||
depends_on:
|
|
||||||
- database
|
|
||||||
networks:
|
|
||||||
- ukds-dev-network
|
|
||||||
|
|
||||||
# Mailhog (Development email testing)
|
|
||||||
mailhog:
|
|
||||||
image: mailhog/mailhog:latest
|
|
||||||
container_name: ukds-dev-mailhog
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "8025:8025" # Web interface
|
|
||||||
- "1025:1025" # SMTP server
|
|
||||||
networks:
|
|
||||||
- ukds-dev-network
|
|
||||||
|
|
||||||
# Networks
|
|
||||||
networks:
|
|
||||||
ukds-dev-network:
|
|
||||||
driver: bridge
|
|
||||||
|
|
||||||
# Volumes
|
|
||||||
volumes:
|
|
||||||
dev_mysql_data:
|
|
||||||
driver: local
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
|
||||||
web:
|
|
||||||
build: .
|
|
||||||
container_name: ukdataservices-web
|
|
||||||
ports:
|
|
||||||
- "80:80"
|
|
||||||
volumes:
|
|
||||||
- ./logs:/var/www/html/logs
|
|
||||||
environment:
|
|
||||||
- APACHE_DOCUMENT_ROOT=/var/www/html
|
|
||||||
- DB_HOST=mysql
|
|
||||||
- DB_USER=webuser
|
|
||||||
- DB_PASSWORD=webpassword
|
|
||||||
- DB_NAME=ukdataservices
|
|
||||||
depends_on:
|
|
||||||
- mysql
|
|
||||||
networks:
|
|
||||||
- ukds-network
|
|
||||||
|
|
||||||
mysql:
|
|
||||||
image: mysql:8.0
|
|
||||||
container_name: ukdataservices-db
|
|
||||||
environment:
|
|
||||||
MYSQL_ROOT_PASSWORD: rootpassword
|
|
||||||
MYSQL_DATABASE: ukdataservices
|
|
||||||
MYSQL_USER: webuser
|
|
||||||
MYSQL_PASSWORD: webpassword
|
|
||||||
MYSQL_ROOT_HOST: '%'
|
|
||||||
ports:
|
|
||||||
- "3306:3306"
|
|
||||||
volumes:
|
|
||||||
- mysql_data:/var/lib/mysql
|
|
||||||
- ./database:/docker-entrypoint-initdb.d
|
|
||||||
networks:
|
|
||||||
- ukds-network
|
|
||||||
command: --default-authentication-plugin=mysql_native_password
|
|
||||||
|
|
||||||
networks:
|
|
||||||
ukds-network:
|
|
||||||
driver: bridge
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
mysql_data:
|
|
||||||
@@ -1,164 +0,0 @@
|
|||||||
# UK Data Services - Production Docker Compose Configuration
|
|
||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
|
||||||
# Web Application
|
|
||||||
web:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile-optimized
|
|
||||||
container_name: ukds-web
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "80:80"
|
|
||||||
- "443:443"
|
|
||||||
volumes:
|
|
||||||
# Persistent logs
|
|
||||||
- ./logs:/var/www/html/logs
|
|
||||||
# Upload directory for file processing
|
|
||||||
- ./uploads:/var/www/html/uploads
|
|
||||||
# Cache directory for performance
|
|
||||||
- ./cache:/var/www/html/cache
|
|
||||||
# SSL certificates (if using HTTPS)
|
|
||||||
- ./ssl:/etc/ssl/certs/ukds:ro
|
|
||||||
environment:
|
|
||||||
- APACHE_DOCUMENT_ROOT=/var/www/html
|
|
||||||
- PHP_MEMORY_LIMIT=256M
|
|
||||||
- PHP_MAX_EXECUTION_TIME=300
|
|
||||||
- PHP_UPLOAD_MAX_FILESIZE=50M
|
|
||||||
- PHP_POST_MAX_SIZE=50M
|
|
||||||
# Database connection
|
|
||||||
- DB_HOST=database
|
|
||||||
- DB_NAME=ukdataservices
|
|
||||||
- DB_USER=webuser
|
|
||||||
- DB_PASSWORD=secure_web_password_2025
|
|
||||||
# Application settings
|
|
||||||
- SITE_URL=https://ukdataservices.co.uk
|
|
||||||
- CONTACT_EMAIL=info@ukdataservices.co.uk
|
|
||||||
- ANALYTICS_ID=GA_MEASUREMENT_ID
|
|
||||||
# Security settings
|
|
||||||
- SECURITY_SALT=your-unique-security-salt-here
|
|
||||||
- API_SECRET_KEY=your-api-secret-key-here
|
|
||||||
depends_on:
|
|
||||||
- database
|
|
||||||
- redis
|
|
||||||
networks:
|
|
||||||
- ukds-network
|
|
||||||
labels:
|
|
||||||
- "traefik.enable=true"
|
|
||||||
- "traefik.http.routers.ukds.rule=Host(`ukdataservices.co.uk`)"
|
|
||||||
- "traefik.http.routers.ukds.tls=true"
|
|
||||||
- "traefik.http.routers.ukds.tls.certresolver=letsencrypt"
|
|
||||||
|
|
||||||
# Database
|
|
||||||
database:
|
|
||||||
image: mysql:8.0
|
|
||||||
container_name: ukds-database
|
|
||||||
restart: unless-stopped
|
|
||||||
environment:
|
|
||||||
MYSQL_ROOT_PASSWORD: secure_root_password_2025
|
|
||||||
MYSQL_DATABASE: ukdataservices
|
|
||||||
MYSQL_USER: webuser
|
|
||||||
MYSQL_PASSWORD: secure_web_password_2025
|
|
||||||
MYSQL_CHARACTER_SET_SERVER: utf8mb4
|
|
||||||
MYSQL_COLLATION_SERVER: utf8mb4_unicode_ci
|
|
||||||
ports:
|
|
||||||
- "3306:3306"
|
|
||||||
volumes:
|
|
||||||
# Persistent database storage
|
|
||||||
- mysql_data:/var/lib/mysql
|
|
||||||
# Database initialization scripts
|
|
||||||
- ./database/init:/docker-entrypoint-initdb.d:ro
|
|
||||||
# Database configuration
|
|
||||||
- ./database/my.cnf:/etc/mysql/conf.d/custom.cnf:ro
|
|
||||||
command: --default-authentication-plugin=mysql_native_password
|
|
||||||
networks:
|
|
||||||
- ukds-network
|
|
||||||
labels:
|
|
||||||
- "traefik.enable=false"
|
|
||||||
|
|
||||||
# Redis Cache (for performance)
|
|
||||||
redis:
|
|
||||||
image: redis:7-alpine
|
|
||||||
container_name: ukds-redis
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "6379:6379"
|
|
||||||
volumes:
|
|
||||||
- redis_data:/data
|
|
||||||
- ./redis/redis.conf:/etc/redis/redis.conf:ro
|
|
||||||
command: redis-server /etc/redis/redis.conf
|
|
||||||
networks:
|
|
||||||
- ukds-network
|
|
||||||
labels:
|
|
||||||
- "traefik.enable=false"
|
|
||||||
|
|
||||||
# Backup Service
|
|
||||||
backup:
|
|
||||||
image: alpine:latest
|
|
||||||
container_name: ukds-backup
|
|
||||||
restart: "no"
|
|
||||||
volumes:
|
|
||||||
- mysql_data:/backup/mysql:ro
|
|
||||||
- ./backups:/backups
|
|
||||||
- ./logs:/backup/logs:ro
|
|
||||||
command: |
|
|
||||||
sh -c "
|
|
||||||
apk add --no-cache mysql-client tar gzip &&
|
|
||||||
while true; do
|
|
||||||
echo 'Starting backup at:' $$(date)
|
|
||||||
mysqldump -h database -u root -psecure_root_password_2025 ukdataservices > /backups/ukds_$$(date +%Y%m%d_%H%M%S).sql
|
|
||||||
tar -czf /backups/logs_$$(date +%Y%m%d_%H%M%S).tar.gz -C /backup/logs .
|
|
||||||
find /backups -name '*.sql' -mtime +7 -delete
|
|
||||||
find /backups -name '*.tar.gz' -mtime +7 -delete
|
|
||||||
echo 'Backup completed at:' $$(date)
|
|
||||||
sleep 86400
|
|
||||||
done
|
|
||||||
"
|
|
||||||
depends_on:
|
|
||||||
- database
|
|
||||||
networks:
|
|
||||||
- ukds-network
|
|
||||||
|
|
||||||
# Monitoring (optional)
|
|
||||||
monitoring:
|
|
||||||
image: prom/node-exporter:latest
|
|
||||||
container_name: ukds-monitoring
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "9100:9100"
|
|
||||||
volumes:
|
|
||||||
- /proc:/host/proc:ro
|
|
||||||
- /sys:/host/sys:ro
|
|
||||||
- /:/rootfs:ro
|
|
||||||
command:
|
|
||||||
- '--path.procfs=/host/proc'
|
|
||||||
- '--path.rootfs=/rootfs'
|
|
||||||
- '--path.sysfs=/host/sys'
|
|
||||||
- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
|
|
||||||
networks:
|
|
||||||
- ukds-network
|
|
||||||
labels:
|
|
||||||
- "traefik.enable=false"
|
|
||||||
|
|
||||||
# Networks
|
|
||||||
networks:
|
|
||||||
ukds-network:
|
|
||||||
driver: bridge
|
|
||||||
ipam:
|
|
||||||
config:
|
|
||||||
- subnet: 172.20.0.0/16
|
|
||||||
|
|
||||||
# Persistent Volumes
|
|
||||||
volumes:
|
|
||||||
mysql_data:
|
|
||||||
driver: local
|
|
||||||
redis_data:
|
|
||||||
driver: local
|
|
||||||
|
|
||||||
# Additional configurations for production
|
|
||||||
x-logging: &default-logging
|
|
||||||
driver: "json-file"
|
|
||||||
options:
|
|
||||||
max-size: "10m"
|
|
||||||
max-file: "3"
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
services:
|
|
||||||
web:
|
|
||||||
build: .
|
|
||||||
container_name: ukdataservices-web
|
|
||||||
ports:
|
|
||||||
- "80:80"
|
|
||||||
volumes:
|
|
||||||
- ./logs:/var/www/html/logs
|
|
||||||
environment:
|
|
||||||
- APACHE_DOCUMENT_ROOT=/var/www/html
|
|
||||||
|
|
||||||
mysql:
|
|
||||||
image: mysql:8.0
|
|
||||||
container_name: ukdataservices-db
|
|
||||||
environment:
|
|
||||||
MYSQL_ROOT_PASSWORD: rootpassword
|
|
||||||
MYSQL_DATABASE: ukdataservices
|
|
||||||
MYSQL_USER: webuser
|
|
||||||
MYSQL_PASSWORD: webpassword
|
|
||||||
ports:
|
|
||||||
- "3306:3306"
|
|
||||||
volumes:
|
|
||||||
- mysql_data:/var/lib/mysql
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
mysql_data:
|
|
||||||
Reference in New Issue
Block a user