LAR_Maintenance/Dockerfile

75 lines
2.4 KiB
Docker

# Use PHP with Apache as the base image
FROM php:8.3-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
# PHP
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN sed -i "s|memory_limit = 128M|memory_limit = 256M |g" /etc/sysctl.conf
RUN sed -i "s|upload_max_filesize = 2M|upload_max_filesize = 100M |g" /etc/sysctl.conf
RUN sed -i "s|post_max_size = 8M|post_max_size = 100M |g" /etc/sysctl.conf
# Install Additional System Dependencies
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y \
libzip-dev \
zip \
nodejs \
npm \
cron \
nano \
default-mysql-client
# Clear cache
RUN apt-get autoremove
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Enable Apache mod_rewrite for URL rewriting
RUN a2enmod rewrite
# Install PHP extensions
RUN docker-php-ext-install pdo_mysql zip
# 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
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# Copy the application code
COPY . /var/www/html
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Install project dependencies
RUN composer install --quiet --prefer-dist --no-dev -o
RUN npm install && npm run build
# Setup Crone
RUN mkdir -p /var/log/cron
RUN echo "* * * * * www-data cd /var/www/html && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1" >> /etc/crontab
RUN echo "* * * * * www-data cd /var/www/html && /usr/local/bin/php artisan queue:work --queue=default --stop-when-empty >> /dev/null 2>&1" >> /etc/crontab
RUN echo "#" >> /etc/crontab
# Add a command to base-image entrypont scritp
RUN sed -i 's/^exec /printenv > \/etc\/environment\n\nexec /' /usr/local/bin/apache2-foreground
RUN sed -i 's/^exec /service cron start\n\nexec /' /usr/local/bin/apache2-foreground
#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/app
RUN mkdir -p /config
VOLUME /config
# Start Apache
WORKDIR /var/www/html/