mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 21:54:14 -08:00
104 lines
3.5 KiB
Docker
104 lines
3.5 KiB
Docker
ARG ENVIRONMENT=production
|
|
ARG SNIPEIT_RELEASE=6.1.0
|
|
ARG PHP_VERSION=8.2
|
|
ARG PHP_ALPINE_VERSION=3.17
|
|
ARG COMPOSER_VERSION=2
|
|
|
|
# Cannot use arguments with 'COPY --from' workaround
|
|
# https://github.com/moby/moby/issues/34482#issuecomment-454716952
|
|
FROM composer:${COMPOSER_VERSION} AS composer
|
|
|
|
# Final stage
|
|
FROM php:${PHP_VERSION}-fpm-alpine${PHP_ALPINE_VERSION} AS source
|
|
LABEL maintainer="Mateus Villar <mromeravillar@gmail.com>"
|
|
|
|
ARG PACKAGES="\
|
|
mysql-client \
|
|
"
|
|
ARG DEV_PACKAGES="\
|
|
git \
|
|
"
|
|
ARG ENVIRONMENT
|
|
ENV ENVIRONMENT ${ENVIRONMENT}
|
|
ARG SNIPEIT_RELEASE
|
|
ENV SNIPEIT_RELEASE ${SNIPEIT_RELEASE}
|
|
|
|
# Cribbed from wordpress-fpm-alpine image
|
|
# set recommended PHP.ini settings
|
|
# see https://secure.php.net/manual/en/opcache.installation.php
|
|
RUN set -eux; \
|
|
docker-php-ext-enable opcache; \
|
|
{ \
|
|
echo 'opcache.memory_consumption=128'; \
|
|
echo 'opcache.interned_strings_buffer=8'; \
|
|
echo 'opcache.max_accelerated_files=4000'; \
|
|
echo 'opcache.revalidate_freq=2'; \
|
|
echo 'opcache.fast_shutdown=1'; \
|
|
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
|
|
# https://wordpress.org/support/article/editing-wp-config-php/#configure-error-logging
|
|
RUN { \
|
|
# https://www.php.net/manual/en/errorfunc.constants.php
|
|
# https://github.com/docker-library/wordpress/issues/420#issuecomment-517839670
|
|
echo 'error_reporting = E_ERROR | E_WARNING | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_RECOVERABLE_ERROR'; \
|
|
echo 'display_errors = Off'; \
|
|
echo 'display_startup_errors = Off'; \
|
|
echo 'log_errors = On'; \
|
|
echo 'error_log = /dev/stderr'; \
|
|
echo 'log_errors_max_len = 1024'; \
|
|
echo 'ignore_repeated_errors = On'; \
|
|
echo 'ignore_repeated_source = Off'; \
|
|
echo 'html_errors = Off'; \
|
|
} > /usr/local/etc/php/conf.d/error-logging.ini
|
|
|
|
# Install php extensions inside docker containers easily
|
|
# https://github.com/mlocati/docker-php-extension-installer
|
|
COPY --from=mlocati/php-extension-installer:2.1.15 /usr/bin/install-php-extensions /usr/local/bin/
|
|
RUN set -eux; \
|
|
install-php-extensions \
|
|
bcmath \
|
|
gd \
|
|
ldap \
|
|
mysqli \
|
|
pdo_mysql \
|
|
zip; \
|
|
rm -f /usr/local/bin/install-php-extensions; \
|
|
# Install prerequisites packages
|
|
apk add --no-cache \
|
|
${PACKAGES};
|
|
|
|
COPY --from=composer /usr/bin/composer /usr/local/bin
|
|
ARG COMPOSER_ALLOW_SUPERUSER=1
|
|
RUN set -eux; \
|
|
# Download and extract snipeit tarball
|
|
curl -o snipeit.tar.gz -fL "https://github.com/snipe/snipe-it/archive/v$SNIPEIT_RELEASE.tar.gz"; \
|
|
tar -xzf snipeit.tar.gz --strip-components=1 -C /var/www/html/; \
|
|
rm snipeit.tar.gz; \
|
|
# Install composer php dependencies
|
|
if [ "$ENVIRONMENT" = "production" ]; then \
|
|
echo "production environment detected!"; \
|
|
composer update \
|
|
--no-cache \
|
|
--no-dev \
|
|
--optimize-autoloader \
|
|
--working-dir=/var/www/html; \
|
|
else \
|
|
echo "development environment detected!"; \
|
|
apk add --no-cache \
|
|
${DEV_PACKAGES}; \
|
|
composer update \
|
|
--no-cache \
|
|
--prefer-source \
|
|
--optimize-autoloader \
|
|
--working-dir=/var/www/html; \
|
|
fi; \
|
|
rm -f /usr/local/bin/composer; \
|
|
chown -R www-data:www-data /var/www/html;
|
|
|
|
VOLUME [ "/var/lib/snipeit" ]
|
|
|
|
COPY --chown=www-data:www-data docker/docker-secrets.env /var/www/html/.env
|
|
COPY --chmod=655 docker/startup_alpine_fpm.sh /startup.sh
|
|
COPY docker/column-statistics.cnf /etc/mysql/conf.d/column-statistics.cnf
|
|
ENTRYPOINT [ "/startup.sh" ]
|
|
CMD [ "/startup.sh", "php-fpm" ]
|