Fixes
Build - Docker Image - PROD / publish (push) Has been cancelled
Build - Docker Image - RC / publish (push) Has been cancelled

This commit is contained in:
JonatanRek
2025-11-25 12:18:32 +01:00
parent e70cf5cdf7
commit f3b3a51ef6
7 changed files with 53 additions and 220 deletions
+31 -62
View File
@@ -1,23 +1,18 @@
# Use PHP with Apache as the base image
FROM php:8.4-apache
# Timezone
ENV TZ="Europe/Prague"
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN printf '[Date]\ndate.timezone="%s"\n', $TZ > /usr/local/etc/php/conf.d/tzone.ini
# OPcache
ENV PHP_OPCACHE_VALIDATE_TIMESTAMPS="1" \
# Environment
ENV TZ="Europe/Prague" \
APACHE_DOCUMENT_ROOT="/var/www/html/public" \
PHP_INI_FILE="$PHP_INI_DIR/php.ini" \
PHP_OPCACHE_VALIDATE_TIMESTAMPS="1" \
PHP_OPCACHE_MAX_ACCELERATED_FILES="10000" \
PHP_OPCACHE_MEMORY_CONSUMPTION="192" \
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10"
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10" \
COMPOSER_ALLOW_SUPERUSER=1
# PHP
RUN export PHP_INI_DIR="$PHP_INI_DIR/php.ini"
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \
sed -i "s|memory_limit = 128M|memory_limit = 256M |g" "$PHP_INI_DIR/php.ini" && \
sed -i "s|upload_max_filesize = 2M|upload_max_filesize = 100M |g" "$PHP_INI_DIR/php.ini" && \
sed -i "s|post_max_size = 8M|post_max_size = 100M |g" "$PHP_INI_DIR/php.ini"
# Timezone
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Install Additional System Dependencies
RUN rm -f /etc/apt/apt.conf.d/docker-clean
@@ -35,11 +30,15 @@ RUN --mount=type=cache,target=/var/cache/apt \
postgresql-client \
imagemagick \
libmagickwand-dev \
librsvg2-2 \
librsvg2-dev \
librsvg2-bin \
supervisor && \
git clone https://github.com/Imagick/imagick --depth 1 /tmp/imagick && \
cd /tmp/imagick && \
phpize && \
./configure && \
./configure --with-rsvg && \
ldconfig && \
make && \
make install && \
apt-get autoremove && \
@@ -55,8 +54,16 @@ RUN a2enmod rewrite
RUN docker-php-ext-install pdo_mysql pgsql pdo_pgsql zip opcache pcntl sockets
RUN docker-php-ext-enable imagick
# PHP
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_FILE" && \
sed -i "s|memory_limit = 128M|memory_limit = 256M |g" "$PHP_INI_FILE" && \
sed -i "s|upload_max_filesize = 2M|upload_max_filesize = 100M |g" "$PHP_INI_FILE" && \
sed -i "s|post_max_size = 8M|post_max_size = 100M |g" "$PHP_INI_FILE" && \
printf '[Date]\ndate.timezone="%s"\n', $TZ > "$PHP_INI_DIR/conf.d/tzone.ini"
#OPCACHE
RUN echo '[opcache]\n\
RUN echo '\n\
[opcache]\n\
opcache.enable=1\n\
opcache.revalidate_freq=0\n\
opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS}\n\
@@ -67,56 +74,18 @@ opcache.interned_strings_buffer=16\n\
opcache.fast_shutdown=1' >> "$PHP_INI_DIR/conf.d/opcache.ini"
#SUPERVISORD
RUN mkdir -p /var/log/supervisor
COPY supervisor/* /etc/supervisor
# Configure Apache DocumentRoot to point to Laravel's public directory
# and update Apache configuration files
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf && \
sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# Setup Crone
RUN mkdir -p /var/log/cron && \
echo "* * * * * www-data cd /var/www/html && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1" >> /etc/crontab
# Install composer # bun
ENV COMPOSER_ALLOW_SUPERUSER=1
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN chown -R www-data:www-data /var/www/html && \
chmod -R 775 /var/www/html
# Patch Docker Entrypoint
RUN sed -i 's/^exec /printenv > \/etc\/environment\n\nexec /' /usr/local/bin/apache2-foreground && \
# Configure Apache DocumentRoot to point to Laravel's public directory
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf && \
sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf && \
sed -i 's/^exec /printenv > \/etc\/environment\n\nexec /' /usr/local/bin/apache2-foreground && \
sed -i 's/^exec /service cron start\n\nexec /' /usr/local/bin/apache2-foreground
# Install project composer dependencies
USER www-data
COPY --chown=www-data:www-data composer.* /var/www/html
RUN --mount=type=cache,target=/root/.composer/vendor \
composer install --prefer-dist --no-dev -o --no-scripts
# Install project npm dependencies
COPY --chown=www-data:www-data package*.json /var/www/html
RUN npm install
# Copy the application code
COPY --chown=www-data:www-data . /var/www/html
RUN --mount=type=cache,target=/root/.composer/vendor \
composer install --prefer-dist --no-dev -o
RUN npm run build
USER root
# Fix Permissions
RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache && \
chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
#Start Container
RUN chmod +x /var/www/html/start.sh
CMD ["/var/www/html/start.sh"]
# Set the working directory
VOLUME /var/www/html/storage/app
RUN mkdir -p /config
VOLUME /config
EXPOSE 8899
# Start Apache
WORKDIR /var/www/html/