124 lines
3.8 KiB
Docker
124 lines
3.8 KiB
Docker
FROM php:8.3-apache-bookworm@sha256:fa8852a2e01747ffe8c8768bfd6bbc2f296f974aa0de90ee157a66664996d263 AS php-base
|
|
|
|
RUN apt-get -o Acquire::Retries=3 update \
|
|
&& apt-get -o Acquire::Retries=3 install -y --no-install-recommends \
|
|
curl \
|
|
libcurl4-openssl-dev \
|
|
libfreetype6-dev \
|
|
libicu-dev \
|
|
libjpeg62-turbo-dev \
|
|
libonig-dev \
|
|
libpng-dev \
|
|
libxml2-dev \
|
|
libzip-dev \
|
|
freetds-bin \
|
|
freetds-dev \
|
|
tdsodbc \
|
|
unixodbc-dev \
|
|
unzip \
|
|
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
|
&& docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \
|
|
&& docker-php-ext-install -j2 \
|
|
bcmath \
|
|
curl \
|
|
dom \
|
|
exif \
|
|
gd \
|
|
intl \
|
|
mbstring \
|
|
pdo_dblib \
|
|
pdo_odbc \
|
|
pdo_mysql \
|
|
simplexml \
|
|
xml \
|
|
zip \
|
|
&& a2enmod expires headers rewrite \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
FROM m.daocloud.io/docker.io/library/composer:2.8@sha256:5248900ab8b5f7f880c2d62180e40960cd87f60149ec9a1abfd62ac72a02577c AS composer-bin
|
|
|
|
FROM php-base AS vendor
|
|
|
|
COPY --from=composer-bin /usr/bin/composer /usr/local/bin/composer
|
|
|
|
WORKDIR /build
|
|
|
|
COPY composer.json composer.lock ./
|
|
|
|
RUN --mount=type=cache,target=/tmp/composer-cache \
|
|
set -eu; \
|
|
attempt=1; \
|
|
while true; do \
|
|
if COMPOSER_CACHE_DIR=/tmp/composer-cache \
|
|
COMPOSER_MAX_PARALLEL_HTTP=4 \
|
|
composer install \
|
|
--prefer-dist \
|
|
--no-dev \
|
|
--no-interaction \
|
|
--no-progress \
|
|
--no-scripts \
|
|
--optimize-autoloader; then \
|
|
break; \
|
|
fi; \
|
|
if [ "$attempt" -ge 3 ]; then \
|
|
exit 1; \
|
|
fi; \
|
|
attempt=$((attempt + 1)); \
|
|
echo "Composer install failed; retrying ($attempt/3)." >&2; \
|
|
sleep 3; \
|
|
done
|
|
|
|
FROM php-base AS runtime
|
|
|
|
# Keep the existing PHP/Composer cache layers when adding PostgreSQL support.
|
|
RUN apt-get -o Acquire::Retries=3 update \
|
|
&& apt-get -o Acquire::Retries=3 install -y --no-install-recommends libpq-dev \
|
|
&& docker-php-ext-install -j2 pdo_pgsql \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
ARG VCS_REF=unknown
|
|
ARG BUILD_DATE=unknown
|
|
ARG APP_VERSION=3.1.15
|
|
|
|
LABEL com.caiwu.project="CaiWuXiTong" \
|
|
org.opencontainers.image.revision="$VCS_REF" \
|
|
org.opencontainers.image.created="$BUILD_DATE"
|
|
|
|
ENV CAIWU_APP_VERSION="$APP_VERSION" \
|
|
CAIWU_BUILD_COMMIT="$VCS_REF" \
|
|
CAIWU_BUILD_TIME="$BUILD_DATE"
|
|
|
|
WORKDIR /var/www/html
|
|
|
|
COPY --from=vendor /build/vendor /var/www/html/vendor
|
|
COPY --from=frontend /js /var/www/html/public/js
|
|
COPY --from=frontend /css/app.css /var/www/html/public/css/app.css
|
|
COPY --from=frontend /mix-manifest.json /var/www/html/public/mix-manifest.json
|
|
COPY deploy/apache-vhost.conf /etc/apache2/sites-available/000-default.conf
|
|
COPY deploy/freetds.conf /etc/freetds/freetds.conf
|
|
COPY deploy/php.ini /usr/local/etc/php/conf.d/caiwu.ini
|
|
COPY deploy/entrypoint.sh /usr/local/bin/caiwu-entrypoint
|
|
COPY . /var/www/html
|
|
COPY --from=frontend /vendor /var/www/html/public/vendor
|
|
|
|
RUN test -f public/js/auth/common.min.js \
|
|
&& test -f public/css/app.css \
|
|
&& test -f public/mix-manifest.json \
|
|
&& test -f public/vendor/apexcharts/apexcharts.min.js \
|
|
&& test -f public/vendor/js-cookie/js.cookie.js \
|
|
&& test -f public/vendor/quicksand/css/quicksand.css \
|
|
&& chmod +x /usr/local/bin/caiwu-entrypoint \
|
|
&& mkdir -p \
|
|
storage/app/public \
|
|
storage/app/temp \
|
|
storage/app/uploads \
|
|
storage/framework/cache/data \
|
|
storage/framework/sessions \
|
|
storage/framework/views \
|
|
storage/logs \
|
|
bootstrap/cache \
|
|
&& chown -R www-data:www-data storage bootstrap/cache
|
|
|
|
ENTRYPOINT ["caiwu-entrypoint"]
|
|
CMD ["apache2-foreground"]
|