docker
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
# 1. Nginx Gateway Reverse Proxy
|
||||
gateway:
|
||||
image: nginx:alpine
|
||||
container_name: gis_gateway
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
depends_on:
|
||||
- php-app
|
||||
- next-app
|
||||
networks:
|
||||
- gis-network
|
||||
|
||||
# 2. PHP + Apache Web App (for Root Portal, SPBU, Parsil, and Chloropleth)
|
||||
php-app:
|
||||
build: ./docker/php
|
||||
container_name: gis_php_app
|
||||
volumes:
|
||||
- .:/var/www/html
|
||||
environment:
|
||||
- DB_HOST=db
|
||||
- DB_DATABASE=spbu_db
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=rootpassword
|
||||
depends_on:
|
||||
- db
|
||||
networks:
|
||||
- gis-network
|
||||
|
||||
# 3. Next.js App Service
|
||||
next-app:
|
||||
build: ./docker/nextjs
|
||||
container_name: gis_next_app
|
||||
working_dir: /app
|
||||
volumes:
|
||||
- ./sistem-km-next:/app
|
||||
- /app/node_modules # Anonymous volume to isolate node_modules from host machine
|
||||
- /app/.next # Anonymous volume for nextjs build artifacts
|
||||
environment:
|
||||
- NEXT_PUBLIC_SUPABASE_URL=https://gzpvygrsfdtzykyqbnes.supabase.co
|
||||
- NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imd6cHZ5Z3JzZmR0enlreXFibmVzIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzkxNTUxNTIsImV4cCI6MjA5NDczMTE1Mn0.bP4qLY6PVT9UplSxB276tZ5HWClIkiuZ_-Yx3IlL8Dw
|
||||
- SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imd6cHZ5Z3JzZmR0enlreXFibmVzIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc3OTE1NTE1MiwiZXhwIjoyMDk0NzMxMTUyfQ.H8rDKBGeagZnF22lFZwlsqPbDP6_kDurNpt8ZRvAigc
|
||||
- PORT=3000
|
||||
- HOSTNAME=0.0.0.0
|
||||
networks:
|
||||
- gis-network
|
||||
|
||||
# 4. MySQL Database Service
|
||||
db:
|
||||
image: mysql:8.0
|
||||
container_name: gis_db
|
||||
command: --default-authentication-plugin=mysql_native_password
|
||||
ports:
|
||||
- "3307:3306" # Mapped to 3307 on host to avoid conflicts with Laragon/XAMPP
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=rootpassword
|
||||
- MYSQL_DATABASE=spbu_db
|
||||
volumes:
|
||||
- db-data:/var/lib/mysql
|
||||
- ./docker/db/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
|
||||
networks:
|
||||
- gis-network
|
||||
|
||||
# 5. phpMyAdmin (Database Management Web UI)
|
||||
phpmyadmin:
|
||||
image: phpmyadmin:latest
|
||||
container_name: gis_phpmyadmin
|
||||
ports:
|
||||
- "8080:80"
|
||||
environment:
|
||||
- PMA_HOST=db
|
||||
- PMA_USER=root
|
||||
- PMA_PASSWORD=rootpassword
|
||||
depends_on:
|
||||
- db
|
||||
networks:
|
||||
- gis-network
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
|
||||
networks:
|
||||
gis-network:
|
||||
driver: bridge
|
||||
@@ -0,0 +1,16 @@
|
||||
FROM node:20-alpine
|
||||
|
||||
# Install libc6-compat for compatibility with native node modules
|
||||
RUN apk add --no-cache libc6-compat
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Expose Next.js port
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT 3000
|
||||
ENV HOSTNAME "0.0.0.0"
|
||||
|
||||
# Automatically install dependencies (to handle architecture differences between Windows host and Linux container)
|
||||
# and run Next.js in development mode
|
||||
CMD ["sh", "-c", "npm install && npm run dev"]
|
||||
@@ -0,0 +1,39 @@
|
||||
# Increase buffer limits to prevent "400 Bad Request - Request Header Or Cookie Too Large"
|
||||
# These must be in the http context (outside the server block) to be applied during initial request parsing
|
||||
large_client_header_buffers 4 64k;
|
||||
client_header_buffer_size 16k;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
# Increase upload limits for maps or databases if needed
|
||||
client_max_body_size 64M;
|
||||
|
||||
# Next.js Application
|
||||
location /sistem-km-next {
|
||||
proxy_pass http://next-app:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
|
||||
# Standard proxy headers
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Disable buffering for hot module reloading (HMR) / Server Sent Events (SSE)
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
# PHP + Static Web GIS application
|
||||
location / {
|
||||
proxy_pass http://php-app:80;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
FROM php:8.2-apache
|
||||
|
||||
# Install PDO MySQL extension for database connectivity
|
||||
RUN docker-php-ext-install pdo pdo_mysql
|
||||
|
||||
# Enable Apache rewrite module
|
||||
RUN a2enmod rewrite
|
||||
|
||||
# Increase request header field size limit to prevent "Size of a request header field exceeds server limit"
|
||||
RUN echo "LimitRequestFieldSize 65536" >> /etc/apache2/apache2.conf
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# Expose port 80
|
||||
EXPOSE 80
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
$host = 'localhost';
|
||||
$dbname = 'spbu_db'; // Change if your database name is different
|
||||
$username = 'root'; // Default XAMPP username
|
||||
$password = ''; // Default XAMPP password is empty
|
||||
$host = getenv('DB_HOST') ?: 'localhost';
|
||||
$dbname = getenv('DB_DATABASE') ?: 'spbu_db'; // Change if your database name is different
|
||||
$username = getenv('DB_USERNAME') ?: 'root'; // Default XAMPP username
|
||||
$password = getenv('DB_PASSWORD') !== false ? getenv('DB_PASSWORD') : ''; // Default XAMPP password is empty
|
||||
|
||||
try {
|
||||
$pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8mb4", $username, $password);
|
||||
|
||||
Generated
+15
@@ -5815,6 +5815,21 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz",
|
||||
"integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript-eslint": {
|
||||
"version": "8.59.4",
|
||||
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.59.4.tgz",
|
||||
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
$host = 'localhost';
|
||||
$dbname = 'spbu_db'; // Change if your database name is different
|
||||
$username = 'root'; // Default XAMPP username
|
||||
$password = ''; // Default XAMPP password is empty
|
||||
$host = getenv('DB_HOST') ?: 'localhost';
|
||||
$dbname = getenv('DB_DATABASE') ?: 'spbu_db'; // Change if your database name is different
|
||||
$username = getenv('DB_USERNAME') ?: 'root'; // Default XAMPP username
|
||||
$password = getenv('DB_PASSWORD') !== false ? getenv('DB_PASSWORD') : ''; // Default XAMPP password is empty
|
||||
|
||||
try {
|
||||
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
|
||||
|
||||
Reference in New Issue
Block a user