2022-07-21 00:59:34 +02:00
|
|
|
FROM php:8.1-apache
|
2019-11-17 19:07:07 +01:00
|
|
|
|
2021-06-09 09:01:21 +02:00
|
|
|
# Install needed dependencies for PHP build
|
|
|
|
RUN apt-get update && apt-get install -y pkg-config curl libcurl4-openssl-dev libicu-dev \
|
2022-07-21 22:53:59 +02:00
|
|
|
libpng-dev libjpeg-dev libfreetype6-dev gnupg zip libzip-dev libjpeg62-turbo-dev libonig-dev libxslt-dev libwebp-dev vim \
|
2021-06-09 09:01:21 +02:00
|
|
|
&& apt-get -y autoremove && apt-get clean autoclean && rm -rf /var/lib/apt/lists/*
|
|
|
|
|
2022-07-21 22:53:59 +02:00
|
|
|
# Install GD with support for multiple formats
|
|
|
|
RUN docker-php-ext-configure gd \
|
|
|
|
--with-webp \
|
|
|
|
--with-jpeg \
|
|
|
|
--with-freetype \
|
2023-02-05 02:16:30 +01:00
|
|
|
&& docker-php-ext-install -j "$(nproc)" gd pdo_mysql intl bcmath zip xsl
|
2019-11-17 19:07:07 +01:00
|
|
|
|
2022-07-21 23:34:38 +02:00
|
|
|
# Enable opcache and configure it recommended for symfony (see https://symfony.com/doc/current/performance.html)
|
2022-07-21 23:53:40 +02:00
|
|
|
RUN docker-php-ext-enable opcache; \
|
2022-07-21 23:34:38 +02:00
|
|
|
{ \
|
|
|
|
echo 'opcache.memory_consumption=256'; \
|
|
|
|
echo 'opcache.max_accelerated_files=20000'; \
|
|
|
|
echo 'opcache.validate_timestamp=0'; \
|
|
|
|
# Configure Realpath cache for performance
|
|
|
|
echo 'realpath_cache_size=4096K'; \
|
|
|
|
echo 'realpath_cache_ttl=600'; \
|
|
|
|
} > /usr/local/etc/php/conf.d/symfony-recommended.ini
|
|
|
|
|
2022-07-25 22:23:09 +02:00
|
|
|
# Install node and yarn
|
2019-11-17 19:07:07 +01:00
|
|
|
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
|
|
|
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
|
2022-07-25 22:44:41 +02:00
|
|
|
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - && apt-get update && apt-get install -y nodejs yarn && apt-get -y autoremove && apt-get clean autoclean && rm -rf /var/lib/apt/lists/*
|
2019-11-17 19:07:07 +01:00
|
|
|
|
2021-06-09 09:01:21 +02:00
|
|
|
# Install composer
|
2019-11-17 19:07:07 +01:00
|
|
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
|
|
|
|
2021-06-09 09:01:21 +02:00
|
|
|
# Set working dir
|
2019-11-17 19:07:07 +01:00
|
|
|
WORKDIR /var/www/html
|
2021-03-14 22:12:55 +01:00
|
|
|
COPY --chown=www-data:www-data . .
|
2019-11-17 19:07:07 +01:00
|
|
|
|
|
|
|
# Setup apache2
|
|
|
|
RUN a2dissite 000-default.conf
|
|
|
|
COPY ./.docker/symfony.conf /etc/apache2/sites-available/symfony.conf
|
|
|
|
RUN a2ensite symfony.conf
|
2021-03-14 22:12:55 +01:00
|
|
|
RUN a2enmod rewrite
|
2019-11-17 19:07:07 +01:00
|
|
|
|
2021-06-09 09:01:21 +02:00
|
|
|
# Install composer and yarn dependencies for Part-DB
|
2021-03-14 22:12:55 +01:00
|
|
|
USER www-data
|
|
|
|
RUN composer install -a --no-dev && composer clear-cache
|
2022-08-13 01:40:00 +02:00
|
|
|
RUN yarn install && yarn build && yarn cache clean && rm -rf node_modules/
|
2019-11-17 19:07:07 +01:00
|
|
|
|
2023-02-04 23:40:24 +01:00
|
|
|
# Use docker env to output logs to stdout
|
|
|
|
ENV APP_ENV=docker
|
2021-03-14 22:12:55 +01:00
|
|
|
ENV DATABASE_URL="sqlite:///%kernel.project_dir%/uploads/app.db"
|
2019-11-17 19:07:07 +01:00
|
|
|
|
2021-03-14 22:12:55 +01:00
|
|
|
USER root
|
2019-11-17 19:07:07 +01:00
|
|
|
|
2023-02-04 22:44:33 +01:00
|
|
|
# Copy entrypoint to /usr/local/bin and make it executable
|
|
|
|
RUN cp ./.docker/partdb-entrypoint.sh /usr/local/bin/partdb-entrypoint.sh && chmod +x /usr/local/bin/partdb-entrypoint.sh
|
|
|
|
ENTRYPOINT ["partdb-entrypoint.sh", "docker-php-entrypoint"]
|
|
|
|
CMD ["apache2-foreground"]
|
|
|
|
|
|
|
|
EXPOSE 80
|
|
|
|
VOLUME ["/var/www/html/uploads", "/var/www/html/public/media"]
|