|
1 | | -### Extensions |
2 | | -FROM php:8.2-apache as extensions |
| 1 | +### Stage 1: build PHP extensions on PHP 8.4 |
| 2 | +FROM php:8.4-apache AS extensions |
3 | 3 |
|
4 | 4 | LABEL stage=intermediate |
5 | 5 |
|
6 | | -RUN apt-get update && \ |
| 6 | +RUN set -eux; \ |
| 7 | + apt-get update; \ |
7 | 8 | apt-get install -y --no-install-recommends \ |
8 | | - libcurl4-gnutls-dev \ |
9 | 9 | libicu-dev \ |
10 | | - libmcrypt-dev \ |
11 | | - libvpx-dev \ |
12 | | - libxpm-dev \ |
13 | 10 | zlib1g-dev \ |
14 | | - libxml2-dev \ |
15 | | - libexpat1-dev \ |
16 | | - libfreetype6-dev \ |
| 11 | + libzip-dev \ |
| 12 | + libpng-dev \ |
17 | 13 | libjpeg62-turbo-dev \ |
18 | 14 | libwebp-dev \ |
19 | | - libbz2-dev \ |
20 | | - libgmp3-dev \ |
21 | | - libldap2-dev \ |
22 | | - unixodbc-dev \ |
23 | | - libpng-dev \ |
| 15 | + libfreetype6-dev \ |
| 16 | + libgmp-dev \ |
24 | 17 | libpq-dev \ |
25 | | - libaspell-dev \ |
26 | | - libsnmp-dev \ |
27 | | - libpcre3-dev \ |
28 | | - libtidy-dev \ |
29 | | - libzip-dev \ |
30 | | - libonig-dev |
| 18 | + libxml2-dev \ |
| 19 | + libonig-dev; \ |
| 20 | + rm -rf /var/lib/apt/lists/* |
31 | 21 |
|
32 | | -RUN ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/local/include/ |
| 22 | +RUN set -eux; \ |
| 23 | + docker-php-ext-install -j"$(nproc)" bcmath gmp intl opcache pdo_mysql zip |
33 | 24 |
|
34 | | -RUN docker-php-ext-install bcmath && \ |
35 | | - docker-php-ext-install gmp && \ |
36 | | - docker-php-ext-install intl && \ |
37 | | - docker-php-ext-install opcache && \ |
38 | | - docker-php-ext-install pdo_mysql && \ |
39 | | - docker-php-ext-install zip |
| 25 | +RUN set -eux; \ |
| 26 | + docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \ |
| 27 | + docker-php-ext-install -j"$(nproc)" gd |
40 | 28 |
|
41 | 29 | RUN set -eux; \ |
42 | | - docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp; \ |
43 | | - docker-php-ext-install -j "$(nproc)" gd |
44 | | - |
45 | | -RUN echo '\ |
46 | | -opcache.enable=1\n\ |
47 | | -opcache.memory_consumption=256\n\ |
48 | | -opcache.interned_strings_buffer=16\n\ |
49 | | -opcache.max_accelerated_files=16000\n\ |
50 | | -opcache.validate_timestamps=0\n\ |
51 | | -opcache.load_comments=Off\n\ |
52 | | -opcache.save_comments=1\n\ |
53 | | -opcache.fast_shutdown=0\n\ |
54 | | -' >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini |
55 | | - |
56 | | -### Composer |
57 | | -FROM php:8.2-apache as api |
58 | | - |
59 | | -COPY --from=extensions /usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini /usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini |
60 | | -COPY --from=extensions /usr/local/etc/php/conf.d/docker-php-ext-intl.ini /usr/local/etc/php/conf.d/docker-php-ext-intl.ini |
61 | | -COPY --from=extensions /usr/local/lib/php/extensions/no-debug-non-zts-20220829/intl.so /usr/local/lib/php/extensions/no-debug-non-zts-20220829/intl.so |
62 | | -COPY --from=extensions /usr/local/lib/php/extensions/no-debug-non-zts-20220829/bcmath.so /usr/local/lib/php/extensions/no-debug-non-zts-20220829/bcmath.so |
| 30 | + { \ |
| 31 | + echo 'opcache.enable=1'; \ |
| 32 | + echo 'opcache.memory_consumption=256'; \ |
| 33 | + echo 'opcache.interned_strings_buffer=16'; \ |
| 34 | + echo 'opcache.max_accelerated_files=16000'; \ |
| 35 | + echo 'opcache.validate_timestamps=0'; \ |
| 36 | + echo 'opcache.load_comments=Off'; \ |
| 37 | + echo 'opcache.save_comments=1'; \ |
| 38 | + echo 'opcache.fast_shutdown=0'; \ |
| 39 | + } > /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini |
| 40 | + |
| 41 | +### Stage 2: composer install on PHP 8.4 |
| 42 | +FROM php:8.4-apache AS api |
63 | 43 |
|
64 | 44 | LABEL stage=intermediate |
65 | | - |
66 | 45 | WORKDIR /api |
67 | 46 |
|
68 | | -# install git |
69 | | -RUN set -eux; \ |
70 | | - chown www-data:www-data /api; \ |
71 | | - apt-get update && \ |
72 | | - apt-get install -y zip unzip git |
| 47 | +COPY --from=extensions /usr/local/lib/php/extensions/ /usr/local/lib/php/extensions/ |
| 48 | +COPY --from=extensions /usr/local/etc/php/conf.d/ /usr/local/etc/php/conf.d/ |
73 | 49 |
|
74 | | -COPY --chown=www-data:www-data composer.json composer.lock /api/ |
| 50 | +RUN set -eux; \ |
| 51 | + apt-get update; \ |
| 52 | + apt-get install -y --no-install-recommends zip unzip git; \ |
| 53 | + rm -rf /var/lib/apt/lists/* |
75 | 54 |
|
76 | | -COPY --chmod=777 --from=composer /usr/bin/composer /usr/bin/composer |
| 55 | +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer |
77 | 56 |
|
| 57 | +COPY --chown=www-data:www-data composer.json composer.lock /api/ |
78 | 58 | USER www-data |
79 | 59 |
|
80 | 60 | RUN set -eux; \ |
81 | | - /usr/bin/composer install --no-dev \ |
82 | | - --ignore-platform-reqs \ |
83 | | - --no-ansi \ |
84 | | - --no-autoloader \ |
85 | | - --no-interaction \ |
86 | | - --no-scripts |
| 61 | + composer install --no-dev --ignore-platform-reqs --no-ansi --no-autoloader --no-interaction --no-scripts |
87 | 62 |
|
88 | 63 | COPY --chown=www-data:www-data / /api |
89 | 64 |
|
90 | | -RUN rm -rf storage/app/api/scunpacked-data |
91 | | -# RUN git clone https://github.com/StarCitizenWiki/scunpacked-data --branch=master --depth=1 storage/app/api/scunpacked-data |
92 | | - |
93 | | -RUN rm -rf storage/app/api/ScToolBoxLocales |
94 | | -# RUN git clone https://github.com/StarCitizenToolBox/LocalizationData --branch=main --depth=1 storage/app/api/ScToolBoxLocales |
| 65 | +RUN rm -rf storage/app/api/scunpacked-data storage/app/api/ScToolBoxLocales |
95 | 66 |
|
96 | | -RUN /usr/bin/composer dump-autoload --optimize --classmap-authoritative |
| 67 | +RUN composer dump-autoload --optimize --classmap-authoritative |
97 | 68 |
|
98 | | -### Final Image |
99 | | -FROM php:8.2-apache |
| 69 | +### Stage 3: final runtime image on PHP 8.4 |
| 70 | +FROM php:8.4-apache |
100 | 71 |
|
101 | 72 | USER root |
| 73 | +WORKDIR /var/www/html |
102 | 74 |
|
103 | | -RUN apt-get update && \ |
| 75 | +RUN set -eux; \ |
| 76 | + apt-get update; \ |
104 | 77 | apt-get install -y --no-install-recommends \ |
105 | 78 | ffmpeg \ |
106 | | - libfreetype6-dev \ |
107 | | - libjpeg62-turbo-dev \ |
108 | | - libwebp-dev \ |
109 | | - libpng-dev |
110 | | - |
111 | | -WORKDIR /var/www/html |
| 79 | + libfreetype6 \ |
| 80 | + libjpeg62-turbo \ |
| 81 | + libwebp7 \ |
| 82 | + libpng16-16 \ |
| 83 | + libzip4; \ |
| 84 | + rm -rf /var/lib/apt/lists/* |
112 | 85 |
|
113 | 86 | COPY --chown=www-data:www-data --from=api /api /var/www/html |
| 87 | +COPY --from=extensions /usr/local/etc/php/conf.d/ /usr/local/etc/php/conf.d/ |
| 88 | +COPY --from=extensions /usr/local/lib/php/extensions/ /usr/local/lib/php/extensions/ |
| 89 | + |
114 | 90 | COPY ./docker/vhost.conf /etc/apache2/sites-available/000-default.conf |
115 | 91 | COPY --chown=www-data:www-data --chmod=770 ./docker/start.sh /usr/local/bin/start |
116 | | - |
117 | | -COPY --from=extensions /usr/local/etc/php/conf.d/*.ini /usr/local/etc/php/conf.d/ |
118 | | -COPY --from=extensions /usr/local/lib/php/extensions/no-debug-non-zts-20220829/*.so /usr/local/lib/php/extensions/no-debug-non-zts-20220829/ |
119 | | - |
120 | | -RUN sed -i -e "s/extension=zip.so/;extension=zip.so/" /usr/local/etc/php/conf.d/docker-php-ext-zip.ini && \ |
121 | | - echo 'memory_limit = 1G' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini && \ |
122 | | - echo 'max_execution_time = 60' >> /usr/local/etc/php/conf.d/docker-php-executiontime.ini |
123 | | - |
124 | 92 | COPY --chown=www-data:www-data --chmod=770 ./docker/schedule.sh /usr/local/bin/schedule |
125 | 93 |
|
126 | | -RUN chmod -R u+w,g+w /var/www/html/storage; \ |
| 94 | +RUN set -eux; \ |
| 95 | + echo 'memory_limit = 1G' > /usr/local/etc/php/conf.d/docker-php-memlimit.ini; \ |
| 96 | + echo 'max_execution_time = 60' > /usr/local/etc/php/conf.d/docker-php-executiontime.ini; \ |
127 | 97 | a2enmod rewrite |
128 | 98 |
|
129 | 99 | USER www-data |
130 | 100 |
|
131 | | -RUN php artisan storage:link; \ |
| 101 | +RUN set -eux; \ |
| 102 | + php artisan storage:link; \ |
132 | 103 | php artisan optimize |
133 | 104 |
|
134 | 105 | CMD ["/usr/local/bin/start"] |
0 commit comments