|
1 |
| -FROM php:8.3-apache |
| 1 | +# Build stage |
| 2 | +FROM php:8.3-cli-alpine as builder |
2 | 3 |
|
3 |
| -RUN apt-get update && apt-get install -y git |
4 |
| -RUN pecl install -o -f redis && docker-php-ext-enable redis |
5 |
| -RUN pecl install -o -f apcu && docker-php-ext-enable apcu |
6 |
| -RUN docker-php-ext-enable opcache |
7 |
| - |
8 |
| -WORKDIR /var/www/html |
| 4 | +RUN apk add --no-cache --virtual .build-deps autoconf build-base git \ |
| 5 | + && pecl install -o -f redis apcu \ |
| 6 | + && docker-php-ext-enable redis apcu opcache \ |
| 7 | + && rm -rf /tmp/pear |
9 | 8 |
|
| 9 | +WORKDIR /app |
10 | 10 | RUN git clone --depth=1 https://github.com/RobiNN1/phpCacheAdmin.git . \
|
11 |
| - && rm -r .git tests composer.json package.json phpstan.neon phpunit.xml README.md docker-compose.yml Dockerfile |
| 11 | + && rm -rf .git tests composer.json package.json phpstan.neon phpunit.xml README.md docker-compose.yml Dockerfile \ |
| 12 | + && apk del .build-deps |
| 13 | + |
| 14 | +# Final stage |
| 15 | +FROM php:8.3-fpm-alpine |
12 | 16 |
|
13 |
| -RUN chown -R www-data:www-data /var/www/html && chmod -R 755 /var/www/html |
| 17 | +COPY --from=builder /usr/local/lib/php/extensions /usr/local/lib/php/extensions |
| 18 | +COPY --from=builder /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d |
| 19 | +COPY --from=builder /app /var/www/html |
14 | 20 |
|
15 |
| -RUN apt-get remove --purge git -y && apt-get autoremove -y && apt-get clean |
| 21 | +RUN apk add --no-cache nginx \ |
| 22 | + && mkdir -p /var/www/html/tmp \ |
| 23 | + && chown -R nobody:nobody /var/www/html \ |
| 24 | + && chmod -R 777 /var/www/html \ |
| 25 | + && mkdir -p /run/nginx \ |
| 26 | + && echo 'server { \ |
| 27 | + listen 80; \ |
| 28 | + root /var/www/html; \ |
| 29 | + index index.php; \ |
| 30 | + location / { \ |
| 31 | + try_files $uri $uri/ /index.php?$query_string; \ |
| 32 | + } \ |
| 33 | + location ~ \.php$ { \ |
| 34 | + fastcgi_pass 127.0.0.1:9000; \ |
| 35 | + fastcgi_index index.php; \ |
| 36 | + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; \ |
| 37 | + include fastcgi_params; \ |
| 38 | + } \ |
| 39 | +}' > /etc/nginx/http.d/default.conf |
16 | 40 |
|
17 |
| -RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf |
| 41 | +EXPOSE 80 |
18 | 42 |
|
19 |
| -CMD ["apache2-foreground"] |
| 43 | +CMD php-fpm -D && nginx -g 'daemon off;' |
0 commit comments