Fix Bad Gateway: Replace supervisor with entrypoint.sh, fix nginx.conf
This commit is contained in:
+18
-14
@@ -1,27 +1,31 @@
|
||||
# =========================================================
|
||||
# Dockerfile - WebGIS PHP Application
|
||||
# Uses Nginx + PHP-FPM in a single Alpine-based container
|
||||
# Nginx + PHP-FPM on Alpine (managed by entrypoint shell script)
|
||||
# =========================================================
|
||||
|
||||
FROM php:8.2-fpm-alpine
|
||||
|
||||
# Install system dependencies and PHP extensions
|
||||
RUN apk add --no-cache \
|
||||
nginx \
|
||||
supervisor \
|
||||
# Install Nginx and required PHP extensions
|
||||
RUN apk add --no-cache nginx \
|
||||
&& docker-php-ext-install mysqli pdo pdo_mysql \
|
||||
&& docker-php-ext-enable mysqli pdo_mysql
|
||||
|
||||
# CRITICAL: Allow ENV vars from Coolify (DB_HOST, DB_PASS, etc.)
|
||||
# to be readable via getenv() in PHP. PHP-FPM strips env vars by default.
|
||||
RUN echo "" >> /usr/local/etc/php-fpm.d/www.conf \
|
||||
&& echo "[www]" >> /usr/local/etc/php-fpm.d/www.conf \
|
||||
&& echo "clear_env = no" >> /usr/local/etc/php-fpm.d/www.conf
|
||||
|
||||
# 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
|
||||
# Create nginx runtime directories
|
||||
RUN mkdir -p /run/nginx && \
|
||||
mkdir -p /var/log/nginx
|
||||
|
||||
# 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
|
||||
# Copy entrypoint script and make executable
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /var/www/html
|
||||
@@ -29,12 +33,12 @@ WORKDIR /var/www/html
|
||||
# Copy all application files
|
||||
COPY . .
|
||||
|
||||
# Set correct permissions for web files
|
||||
# Set correct permissions
|
||||
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"]
|
||||
# Run entrypoint script
|
||||
CMD ["/entrypoint.sh"]
|
||||
|
||||
Reference in New Issue
Block a user