-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.prod
More file actions
72 lines (59 loc) · 3.73 KB
/
Copy pathDockerfile.prod
File metadata and controls
72 lines (59 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
FROM php:8.3-apache
# ── Apache document root ─────────────────────────────────────
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' \
/etc/apache2/sites-available/*.conf \
&& sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' \
/etc/apache2/apache2.conf \
/etc/apache2/conf-available/*.conf \
&& a2enmod rewrite
# ── System dependencies ──────────────────────────────────────
RUN apt-get update && apt-get install -y --no-install-recommends \
git curl unzip netcat-openbsd \
zlib1g-dev libicu-dev g++ \
libpng-dev libjpeg-dev libfreetype6-dev \
libmagickwand-dev \
&& rm -rf /var/lib/apt/lists/*
# ── PHP extensions ───────────────────────────────────────────
RUN pecl install imagick \
&& docker-php-ext-configure intl \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install mysqli intl pdo pdo_mysql gd \
&& docker-php-ext-enable imagick
# ── PHP production settings ──────────────────────────────────
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
&& echo "upload_max_filesize = 20M" >> "$PHP_INI_DIR/conf.d/app.ini" \
&& echo "post_max_size = 25M" >> "$PHP_INI_DIR/conf.d/app.ini" \
&& echo "memory_limit = 256M" >> "$PHP_INI_DIR/conf.d/app.ini"
# ── Composer ─────────────────────────────────────────────────
COPY --from=composer/composer:latest-bin /composer /usr/bin/composer
# ── Apache CalDAV config ─────────────────────────────────────
COPY docker/apache-caldav.conf /etc/apache2/conf-available/caldav.conf
RUN a2enconf caldav
# ── Application source ───────────────────────────────────────
WORKDIR /var/www/html
COPY . .
# ── PHP dependencies (no dev, optimized autoloader) ──────────
RUN APP_ENV=prod composer install \
--no-dev \
--optimize-autoloader \
--no-interaction \
--no-progress
# ── Compile AssetMapper assets ───────────────────────────────
# A dummy APP_SECRET is used only for the DI container compile;
# it is not embedded in the compiled assets.
RUN APP_ENV=prod APP_SECRET=buildsecret \
php bin/console asset-map:compile --no-interaction
# ── Warm Symfony DI container cache ──────────────────────────
RUN APP_ENV=prod APP_SECRET=buildsecret \
DATABASE_URL="mysql://x:x@localhost/x" \
php bin/console cache:warmup --no-interaction || true
# ── Persistent directories & permissions ─────────────────────
RUN mkdir -p public/uploads/cars public/uploads/users public/media/cache var/cache var/log var/uploads/messages var/uploads/handbooks \
&& chown -R www-data:www-data var/ public/uploads/ public/media/cache/ \
&& chmod -R 775 var/ public/uploads/ public/media/cache/
# ── Entrypoint ───────────────────────────────────────────────
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["apache2-foreground"]