feat: add Docker setup exposing app on port 7876
- Dockerfile: php:apache base, installs PHP extensions + Composer, configures Apache to listen on port 7876, bundles app code, runs composer install at build time - docker-compose.yml: web service (port 7876) + MariaDB LTS with healthcheck; writable volume for DB persistence - docker/entrypoint.sh: generates .env from environment variables at container start, fixes runtime permissions - docker/php.ini: tuned PHP limits (512M memory, 32M upload) - .dockerignore: excludes .git, vendor, logs, cache, old docker dir - .env.example: template for required environment variables Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
52
Dockerfile
Normal file
52
Dockerfile
Normal file
@@ -0,0 +1,52 @@
|
||||
FROM php:apache
|
||||
|
||||
# Build-time deps for PHP extensions
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libicu-dev libzip-dev libpng-dev libjpeg62-turbo-dev libfreetype6-dev \
|
||||
libxml2-dev libcurl4-openssl-dev libonig-dev pkg-config unzip git tzdata \
|
||||
&& docker-php-ext-configure gd --with-jpeg --with-freetype \
|
||||
&& docker-php-ext-install -j"$(nproc)" \
|
||||
pdo pdo_mysql mysqli intl zip gd bcmath mbstring curl xml \
|
||||
&& a2enmod rewrite headers \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Composer from official image
|
||||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Configure Apache to listen on port 7876
|
||||
RUN sed -i 's/Listen 80/Listen 7876/' /etc/apache2/ports.conf \
|
||||
&& sed -i 's/<VirtualHost \*:80>/<VirtualHost *:7876>/' /etc/apache2/sites-available/000-default.conf
|
||||
|
||||
# Set Apache DocumentRoot to /var/www/html/public
|
||||
RUN sed -ri -e 's!/var/www/html!/var/www/html/public!g' /etc/apache2/sites-available/000-default.conf
|
||||
|
||||
# Apache request timeout
|
||||
RUN echo "Timeout 300" > /etc/apache2/conf-available/timeouts.conf && a2enconf timeouts
|
||||
|
||||
# PHP config
|
||||
COPY docker/php.ini /usr/local/etc/php/conf.d/custom.ini
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# Copy application source
|
||||
COPY . .
|
||||
|
||||
# Install Composer dependencies
|
||||
RUN composer install --no-interaction --prefer-dist --no-dev --optimize-autoloader
|
||||
|
||||
# Base permissions: code owned root:www-data, writable dirs owned www-data
|
||||
RUN chown -R root:www-data /var/www/html \
|
||||
&& find /var/www/html -type d -exec chmod 755 {} \; \
|
||||
&& find /var/www/html -type f -exec chmod 644 {} \; \
|
||||
&& mkdir -p logs cache public/assets/uploads/avatars \
|
||||
&& chown -R www-data:www-data logs cache public/assets/uploads \
|
||||
&& chmod -R 775 logs cache public/assets/uploads \
|
||||
&& chmod 775 /var/www/html
|
||||
|
||||
COPY docker/entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
EXPOSE 7876
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD ["apache2-foreground"]
|
||||
Reference in New Issue
Block a user