- Remove outdated Unit-based Docker configuration and scripts. - Introduce Nginx + PHP-FPM stack with environment-based configurations. - Add custom Nginx setup for frontend-backend routing. - Update Dockerfiles, Docker Compose, and related scripts for new architecture.
102 lines
2.9 KiB
Docker
102 lines
2.9 KiB
Docker
FROM docker.io/php:8.5-fpm-alpine3.23 AS build
|
|
|
|
RUN apk --no-cache add pcre2 libbz2 libpng libwebp libjpeg-turbo icu-libs freetype oniguruma libzip jq \
|
|
&& apk add --no-cache --virtual .phpize-deps icu-dev libpng-dev bzip2-dev libwebp-dev libjpeg-turbo-dev freetype-dev oniguruma-dev libzip-dev pcre2-dev ${PHPIZE_DEPS} \
|
|
&& docker-php-ext-configure intl --enable-intl && \
|
|
docker-php-ext-configure bcmath --enable-bcmath && \
|
|
docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp && \
|
|
docker-php-ext-install -j$(nproc) gd && \
|
|
docker-php-ext-install bcmath &&\
|
|
docker-php-ext-install pdo \
|
|
mysqli pdo_mysql \
|
|
intl mbstring \
|
|
zip pcntl \
|
|
exif bz2 \
|
|
calendar \
|
|
&& pear update-channels && pecl update-channels \
|
|
&& pecl install redis && docker-php-ext-enable redis \
|
|
&& rm -rf /tmp/pear \
|
|
&& docker-php-source delete \
|
|
&& apk del .phpize-deps \
|
|
&& rm -rf /var/cache/apk/* && rm -rf /etc/apk/cache \
|
|
&& rm -rf /usr/share/php && rm -rf /tmp/* \
|
|
&& rm "$PHP_INI_DIR/php.ini-development" \
|
|
&& mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
|
|
&& mkdir -p /tmp/php/upload \
|
|
&& mkdir -p /tmp/php/sys \
|
|
&& mkdir -p /tmp/php/session \
|
|
&& chown -R www-data:www-data /tmp/php
|
|
|
|
COPY docker/php/conf/app-fpm.conf /usr/local/etc/php-fpm.d/app-fpm.conf
|
|
|
|
FROM build AS app_build_for_production
|
|
WORKDIR /home/app
|
|
|
|
COPY application /home/app
|
|
|
|
RUN apk --no-cache add git \
|
|
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
|
|
&& composer install --optimize-autoloader --no-dev \
|
|
&& rm -rf /home/app/.env
|
|
|
|
|
|
FROM build AS production
|
|
|
|
COPY --from=app_build_for_production /home/app /var/www/html
|
|
COPY docker/php/start.sh /usr/local/bin/start
|
|
|
|
WORKDIR /var/www/html
|
|
|
|
RUN chown -R www-data:www-data /var/www/html \
|
|
&& chmod 755 /usr/local/bin/start
|
|
|
|
STOPSIGNAL SIGTERM
|
|
|
|
USER www-data
|
|
|
|
EXPOSE 9000
|
|
CMD ["/usr/local/bin/start"]
|
|
|
|
|
|
FROM build AS develop
|
|
|
|
WORKDIR /var/www/html
|
|
|
|
COPY docker/php/start.sh /usr/local/bin/start
|
|
|
|
STOPSIGNAL SIGTERM
|
|
|
|
RUN chmod 755 /usr/local/bin/start \
|
|
&& apk --no-cache add git nodejs npm \
|
|
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
|
|
|
USER www-data
|
|
|
|
EXPOSE 9000
|
|
CMD ["/usr/local/bin/start"]
|
|
|
|
|
|
|
|
FROM build AS artisan
|
|
WORKDIR /var/www/html
|
|
STOPSIGNAL SIGTERM
|
|
ENTRYPOINT ["php", "/var/www/html/artisan"]
|
|
|
|
|
|
FROM build AS composer
|
|
WORKDIR /var/www/html
|
|
STOPSIGNAL SIGTERM
|
|
RUN apk --no-cache add git \
|
|
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
|
RUN mkdir "/.composer" && chmod -R 0777 "/.composer"
|
|
ENTRYPOINT ["composer"]
|
|
|
|
|
|
|
|
FROM build AS npm
|
|
RUN mkdir "/.npm" && chmod -R 0777 "/.npm"
|
|
WORKDIR /var/www/html
|
|
STOPSIGNAL SIGTERM
|
|
RUN apk --no-cache add nodejs npm
|
|
ENTRYPOINT ["npm"]
|