-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.local
66 lines (51 loc) · 1.77 KB
/
Dockerfile.local
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Use PHP official image with Apache
FROM php:8.2-apache
# Install system dependencies for PHP extensions and other utilities
RUN apt-get update && apt-get install -y \
libpq-dev \
libpng-dev \
libonig-dev \
libxml2-dev \
libzip-dev \
libicu-dev \
zip \
unzip \
git \
curl \
postgresql-client \
nodejs \
npm \
&& docker-php-ext-install pdo_pgsql pgsql mbstring exif pcntl bcmath gd intl zip \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Enable Apache mod_rewrite
RUN a2enmod rewrite
# Set working directory
WORKDIR /var/www
# Set Apache DocumentRoot to public directory
ENV APACHE_DOCUMENT_ROOT /var/www/public
# Configure Apache to serve the correct 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
# Copy existing application directory contents
COPY . /var/www
# Copy .env.example to .env
RUN cp /var/www/.env.example /var/www/.env
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Install Composer dependencies
RUN composer install --no-dev --optimize-autoloader
# Install Node.js dependencies and build assets
RUN npm install \
&& npm run build
# Create sail user and set permissions
RUN useradd -m sail
RUN chown -R sail:sail /var/www/storage /var/www/bootstrap/cache /var/www/database /var/www/.env /var/www/storage/logs/laravel.log
RUN chmod -R 775 /var/www/storage /var/www/bootstrap/cache /var/www/database /var/www/.env /var/www/storage/logs/laravel.log
# Generate APP_KEY
RUN php artisan key:generate
# Switch to sail user
USER sail
# Expose port 80
EXPOSE 80
# Start Apache server
CMD ["apache2-foreground"]