SOFTEDGE / Dockerfile
akra35567's picture
Upload 37 files
2da3758 verified
# ================================
# SoftEdge Corporation — HF Spaces
# PHP 8.3 + Apache (ESTÁVEL)
# ================================
FROM php:8.3-apache
# ----------------
# VARIÁVEIS
# ----------------
ENV PORT=7860
ENV APACHE_RUN_USER=www-data
ENV APACHE_RUN_GROUP=www-data
ENV APACHE_LOG_DIR=/var/log/apache2
# ----------------
# DEPENDÊNCIAS DO SISTEMA
# ----------------
RUN apt-get update && apt-get install -y --no-install-recommends \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
libzip-dev \
libicu-dev \
libxml2-dev \
libcurl4-openssl-dev \
libonig-dev \
sqlite3 \
libsqlite3-dev \
git \
curl \
cron \
unzip \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# ----------------
# EXTENSÕES PHP (CONTROLADAS)
# ----------------
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install \
mbstring \
exif \
bcmath \
intl \
zip \
gd \
mysqli \
pdo \
pdo_mysql \
pdo_sqlite \
&& docker-php-ext-enable \
mbstring exif bcmath intl zip gd mysqli pdo_mysql pdo_sqlite
# 🔥 LIMPEZA DE INIs DUPLICADOS (CRÍTICO)
RUN find /usr/local/etc/php/conf.d -type f -name "*docker-php-ext-*" -exec sed -i '/^extension=/d' {} \;
# ----------------
# COMPOSER
# ----------------
RUN curl -sS https://getcomposer.org/installer | php -- \
--install-dir=/usr/local/bin \
--filename=composer
# ----------------
# NODE (opcional p/ React)
# ----------------
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& node -v && npm -v
# ----------------
# APACHE CONFIG
# ----------------
RUN a2enmod rewrite headers
# ServerName GLOBAL (remove AH00558 de vez)
RUN echo "ServerName localhost" > /etc/apache2/conf-available/servername.conf \
&& a2enconf servername
# Porta HF Spaces
RUN sed -i 's/Listen 80/Listen 7860/' /etc/apache2/ports.conf
RUN printf '<VirtualHost *:7860>\n\
ServerName localhost\n\
DocumentRoot /var/www/html\n\
<Directory /var/www/html>\n\
AllowOverride All\n\
Require all granted\n\
</Directory>\n\
ErrorLog ${APACHE_LOG_DIR}/error.log\n\
CustomLog ${APACHE_LOG_DIR}/access.log combined\n\
</VirtualHost>\n' > /etc/apache2/sites-available/000-default.conf
# ----------------
# APP
# ----------------
WORKDIR /var/www/html
COPY . .
# Logs e storage
RUN mkdir -p logs storage \
&& chown -R www-data:www-data /var/www/html \
&& chmod -R 775 logs storage
# ----------------
# COMPOSER INSTALL
# ----------------
RUN if [ -f composer.json ]; then \
composer install --no-dev --optimize-autoloader --no-interaction; \
fi
# ----------------
# REACT BUILD (SE EXISTIR)
# ----------------
RUN if [ -f package.json ]; then \
npm install && npm run build; \
fi
# ----------------
# PHP CONFIG FINAL
# ----------------
RUN printf "display_errors=Off\n\
log_errors=On\n\
error_log=/var/www/html/logs/php_errors.log\n\
memory_limit=256M\n\
upload_max_filesize=10M\n\
post_max_size=10M\n\
max_execution_time=300\n" > /usr/local/etc/php/conf.d/99-softedge.ini
# ----------------
# HEALTHCHECK
# ----------------
RUN echo "<?php http_response_code(200); echo 'OK';" > /var/www/html/health.php
HEALTHCHECK --interval=60s --timeout=5s \
CMD curl -f http://localhost:7860/health.php || exit 1
# ----------------
# START
# ----------------
EXPOSE 7860
CMD ["apache2-foreground"]