Create DockerFilecopy
Browse files- DockerFilecopy +54 -0
DockerFilecopy
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use the official PHP image with PHP 8.1
|
2 |
+
FROM php:8.1-apache
|
3 |
+
|
4 |
+
# Install necessary packages and PHP extensions
|
5 |
+
RUN apt-get update && apt-get install -y \
|
6 |
+
wget \
|
7 |
+
git \
|
8 |
+
gnupg \
|
9 |
+
lsb-release \
|
10 |
+
apt-transport-https \
|
11 |
+
ca-certificates \
|
12 |
+
libpq-dev \
|
13 |
+
libsqlite3-dev \
|
14 |
+
zip \
|
15 |
+
unzip \
|
16 |
+
&& docker-php-ext-install pgsql pdo_pgsql pdo_sqlite mysqli pdo_mysql
|
17 |
+
|
18 |
+
# Install Composer
|
19 |
+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
20 |
+
|
21 |
+
# Copy the Laravel project into the container
|
22 |
+
COPY ./php/ /var/www/html
|
23 |
+
|
24 |
+
# Ensure .env file is copied
|
25 |
+
COPY ./php/.env /var/www/html/.env
|
26 |
+
|
27 |
+
# Run composer update to ensure compatible versions of dependencies
|
28 |
+
RUN composer update --working-dir=/var/www/html --no-scripts
|
29 |
+
|
30 |
+
# Set Apache DocumentRoot to Laravel's public directory
|
31 |
+
RUN sed -i 's|/var/www/html|/var/www/html/public|' /etc/apache2/sites-available/000-default.conf
|
32 |
+
|
33 |
+
# Change Apache to listen on port 7860
|
34 |
+
RUN sed -i 's/Listen 80/Listen 7860/' /etc/apache2/ports.conf \
|
35 |
+
&& sed -i 's/:80/:7860/' /etc/apache2/sites-available/000-default.conf
|
36 |
+
|
37 |
+
# Set correct permissions for Laravel directories
|
38 |
+
RUN chown -R www-data:www-data /var/www/html \
|
39 |
+
&& find /var/www/html -type d -exec chmod 755 {} \; \
|
40 |
+
&& find /var/www/html -type f -exec chmod 644 {} \;
|
41 |
+
|
42 |
+
# Ensure the storage and cache directories have the correct permissions
|
43 |
+
RUN mkdir -p /var/www/html/storage \
|
44 |
+
&& mkdir -p /var/www/html/bootstrap/cache \
|
45 |
+
&& chown -R www-data:www-data /var/www/html/storage \
|
46 |
+
&& chown -R www-data:www-data /var/www/html/bootstrap/cache \
|
47 |
+
&& chmod -R 775 /var/www/html/storage \
|
48 |
+
&& chmod -R 775 /var/www/html/bootstrap/cache
|
49 |
+
|
50 |
+
# Expose the Apache port
|
51 |
+
EXPOSE 7860
|
52 |
+
|
53 |
+
# Start Apache
|
54 |
+
CMD ["apache2-foreground"]
|