-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
50 lines (35 loc) · 1.53 KB
/
dockerfile
File metadata and controls
50 lines (35 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
FROM php:8.2-apache
# Install system dependencies
RUN apt-get update && apt-get install -y \
zip unzip curl npm git libzip-dev libssl-dev pkg-config libcurl4-openssl-dev \
&& docker-php-ext-install pdo_mysql zip \
&& pecl install mongodb \
&& docker-php-ext-enable mongodb \
&& a2enmod rewrite
# Install Composer globally
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
WORKDIR /var/www/html
COPY . .
# Fix Apache DocumentRoot to Laravel public folder
RUN sed -i 's|DocumentRoot /var/www/html|DocumentRoot /var/www/html/public|g' /etc/apache2/sites-available/000-default.conf
RUN a2enmod rewrite
RUN echo '<Directory /var/www/html/public>\n\
AllowOverride All\n\
Require all granted\n\
</Directory>' > /etc/apache2/conf-available/laravel.conf && \
a2enconf laravel
# Set permissions for Laravel folders
RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache /var/www/html/public
# Switch to appuser (create if needed)
RUN useradd -m appuser && chown -R appuser /var/www/html
USER appuser
# Install PHP dependencies *with scripts* as appuser
RUN composer install --no-dev --optimize-autoloader --no-interaction --prefer-dist
# Switch back to root for npm install/build
USER root
RUN npm install
RUN npm run build
# Fix permissions so Apache can access storage/cache and public folders again
RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache /var/www/html/public
EXPOSE 80
CMD ["apache2-foreground"]