Dockerize: Add Dockerfile, nginx.conf, supervisord.conf with clear_env=no fix
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
node_modules
|
||||||
|
*.log
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
README.md
|
||||||
+40
@@ -0,0 +1,40 @@
|
|||||||
|
# =========================================================
|
||||||
|
# Dockerfile - WebGIS PHP Application
|
||||||
|
# Uses Nginx + PHP-FPM in a single Alpine-based container
|
||||||
|
# =========================================================
|
||||||
|
|
||||||
|
FROM php:8.2-fpm-alpine
|
||||||
|
|
||||||
|
# Install system dependencies and PHP extensions
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
nginx \
|
||||||
|
supervisor \
|
||||||
|
&& docker-php-ext-install mysqli pdo pdo_mysql \
|
||||||
|
&& docker-php-ext-enable mysqli pdo_mysql
|
||||||
|
|
||||||
|
# Copy Nginx configuration
|
||||||
|
COPY nginx.conf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
# Copy supervisor configuration (runs Nginx + PHP-FPM together)
|
||||||
|
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
|
||||||
|
# CRITICAL: Allow ENV vars (DB_HOST, DB_PASS etc) from Coolify to be
|
||||||
|
# readable by PHP's getenv(). By default PHP-FPM clears all env vars.
|
||||||
|
RUN echo "[www]" >> /usr/local/etc/php-fpm.d/www.conf && \
|
||||||
|
echo "clear_env = no" >> /usr/local/etc/php-fpm.d/www.conf
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
# Copy all application files
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Set correct permissions for web files
|
||||||
|
RUN chown -R www-data:www-data /var/www/html \
|
||||||
|
&& chmod -R 755 /var/www/html
|
||||||
|
|
||||||
|
# Expose port 80
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# Start supervisor (which manages both Nginx and PHP-FPM)
|
||||||
|
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
worker_processes auto;
|
||||||
|
error_log /var/log/nginx/error.log warn;
|
||||||
|
pid /var/run/nginx.pid;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
sendfile on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name _;
|
||||||
|
root /var/www/html;
|
||||||
|
index index.php index.html;
|
||||||
|
|
||||||
|
# Main location block
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
# PHP-FPM handler - all .php files are processed by PHP-FPM
|
||||||
|
location ~ \.php$ {
|
||||||
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Allow access to static files (HTML, CSS, JS, images)
|
||||||
|
location ~* \.(html|css|js|jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||||
|
expires max;
|
||||||
|
access_log off;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Security: deny access to hidden files
|
||||||
|
location ~ /\. {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# PHP-FPM environment variable passthrough
|
||||||
|
# This ensures ENV vars from Coolify are accessible via getenv() in PHP
|
||||||
|
|
||||||
|
; Clear all environment variables (security)
|
||||||
|
clear_env = no
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
[supervisord]
|
||||||
|
nodaemon=true
|
||||||
|
logfile=/var/log/supervisord.log
|
||||||
|
pidfile=/var/run/supervisord.pid
|
||||||
|
|
||||||
|
[program:nginx]
|
||||||
|
command=nginx -g "daemon off;"
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stderr_logfile_maxbytes=0
|
||||||
|
|
||||||
|
[program:php-fpm]
|
||||||
|
command=php-fpm -F
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stderr_logfile_maxbytes=0
|
||||||
Reference in New Issue
Block a user