2024-04-25 20:58:52 +05:00
|
|
|
FROM docker.io/php:8.3-zts-alpine3.18 AS UNIT_BUILDER
|
2023-12-08 21:10:31 +06:00
|
|
|
|
|
|
|
ARG UNIT_VERSION=1.31.1
|
|
|
|
|
|
|
|
RUN apk --no-cache add pcre2-dev gcc git musl-dev make && \
|
|
|
|
mkdir -p /usr/lib/unit/modules && \
|
|
|
|
git clone https://github.com/nginx/unit.git && \
|
|
|
|
cd unit && \
|
|
|
|
git checkout $UNIT_VERSION && \
|
|
|
|
./configure --prefix=/var --statedir=/var/lib/unit --runstatedir=/var/run --control=unix:/run/unit/control.unit.sock --log=/var/log/unit.log --user=www-data --group=www-data --tmpdir=/tmp --modulesdir=/var/lib/unit/modules && \
|
|
|
|
./configure php && \
|
|
|
|
make && \
|
|
|
|
make install
|
|
|
|
|
2024-04-25 20:58:52 +05:00
|
|
|
FROM docker.io/php:8.3-zts-alpine3.18 as BUILD
|
2023-12-08 21:10:31 +06:00
|
|
|
|
|
|
|
COPY --from=UNIT_BUILDER /var/sbin/unitd /usr/sbin/unitd
|
|
|
|
COPY --from=UNIT_BUILDER /var/lib/unit/ /var/lib/unit/
|
|
|
|
|
2024-04-25 19:56:34 +05:00
|
|
|
COPY docker/unit-config.json /docker-entrypoint.d/config.json
|
2023-12-08 21:10:31 +06:00
|
|
|
|
|
|
|
RUN apk --no-cache add pcre2 libbz2 libpng libwebp libjpeg-turbo icu-libs freetype oniguruma libzip \
|
|
|
|
&& 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 opcache 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 \
|
|
|
|
&& ln -sf /dev/stdout /var/log/unit.log \
|
2024-04-25 19:56:34 +05:00
|
|
|
&& addgroup -S unit && adduser -S unit -G unit
|
2023-12-08 21:10:31 +06:00
|
|
|
|
2024-04-25 23:45:07 +05:00
|
|
|
FROM BUILD as APP_BUILD_FOR_PRODUCTION
|
|
|
|
WORKDIR /home/app
|
|
|
|
|
|
|
|
COPY application /home/app
|
|
|
|
|
|
|
|
RUN apk --no-cache add git nodejs npm \
|
|
|
|
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
|
|
|
|
&& composer install --optimize-autoloader --no-dev \
|
|
|
|
&& npm install && npm run build \
|
|
|
|
&& rm -rf /home/app/node_modules /home/app/.env
|
|
|
|
|
|
|
|
|
|
|
|
FROM BUILD AS PRODUCTION
|
|
|
|
|
|
|
|
COPY --from=APP_BUILD_FOR_PRODUCTION /home/app /var/www/html
|
|
|
|
COPY docker/docker-entrypoint_prod.sh /home/unit/docker-entrypoint.sh
|
|
|
|
|
|
|
|
WORKDIR /var/www/html
|
|
|
|
|
|
|
|
RUN chmod 755 /home/unit/docker-entrypoint.sh
|
|
|
|
|
|
|
|
STOPSIGNAL SIGTERM
|
|
|
|
|
|
|
|
ENTRYPOINT ["/home/unit/docker-entrypoint.sh"]
|
|
|
|
EXPOSE 9000
|
|
|
|
CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock", "--user", "unit", "--group", "unit"]
|
2023-12-08 21:10:31 +06:00
|
|
|
|
|
|
|
|
|
|
|
FROM BUILD AS DEVELOP
|
|
|
|
|
|
|
|
WORKDIR /var/www/html
|
|
|
|
|
2024-04-25 19:56:34 +05:00
|
|
|
COPY docker/docker-entrypoint_dev.sh /home/unit/docker-entrypoint.sh
|
|
|
|
|
2023-12-08 21:10:31 +06:00
|
|
|
STOPSIGNAL SIGTERM
|
|
|
|
|
2024-04-25 19:56:34 +05:00
|
|
|
RUN chmod 755 /home/unit/docker-entrypoint.sh \
|
|
|
|
&& apk --no-cache add git nodejs npm \
|
|
|
|
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
2023-12-08 21:10:31 +06:00
|
|
|
|
|
|
|
ENTRYPOINT ["/home/unit/docker-entrypoint.sh"]
|
2024-04-25 19:56:34 +05:00
|
|
|
|
2023-12-08 21:10:31 +06:00
|
|
|
EXPOSE 9000
|
|
|
|
CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock", "--user", "unit", "--group", "unit"]
|
2024-04-25 19:56:34 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 \
|
2024-04-25 23:45:07 +05:00
|
|
|
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
|
|
|
|
&& mkdir /.composer && chmod 0777 /.composer
|
2024-04-25 19:56:34 +05:00
|
|
|
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"]
|