-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
70 lines (55 loc) · 1.99 KB
/
Dockerfile
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
67
68
69
70
# 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_mysql 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
# Create necessary directories
RUN mkdir -p /var/www/storage/logs \
/var/www/storage/framework/{cache,sessions,views,testing} \
/var/www/bootstrap/cache
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Copy existing application directory contents
COPY . /var/www
# Install Composer dependencies
RUN composer install --no-dev --optimize-autoloader
# Install Node.js dependencies and build assets
RUN npm install \
&& npm run build
# Set correct permissions for storage, database and logs
RUN chown -R $(whoami):$(whoami) /var/www/storage /var/www/bootstrap/cache /var/www/database \
&& chmod -R 775 /var/www/storage /var/www/bootstrap/cache /var/www/database /var/www/storage/logs
# Copy custom Apache configuration
COPY ports.conf /etc/apache2/ports.conf
COPY apache2.conf /etc/apache2/apache2.conf
COPY 000-default.conf /etc/apache2/sites-available/000-default.conf
# Generate APP_KEY
RUN echo "APP_KEY=" > .env
RUN php artisan key:generate
# Expose ports
EXPOSE 8080 443
# Start Apache server
CMD ["apache2-foreground"]