-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
56 lines (43 loc) · 1.57 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
FROM php:8.2-apache
# Install required system dependencies and enable Apache mod_rewrite
RUN apt-get update && apt-get install -y \
libzip-dev zip unzip \
libsqlite3-dev sqlite3 \
&& docker-php-ext-install zip pdo pdo_sqlite \
&& a2enmod rewrite \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Copy .env file
COPY .env.example .env
RUN chmod 644 .env
# Configure Apache to serve Laravel's public directory
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 \
&& sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# Set working directory
WORKDIR /var/www/html
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Set up environment for composer
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV COMPOSER_HOME=/tmp/composer
# Add environment variable for TMDB API key
ENV TMDB_API_KEY=65c16f65408eb50e3e67c21262201775
# Copy application files
COPY . .
# Create Laravel directory structure and set permissions
RUN mkdir -p storage/framework/{sessions,views,cache} \
storage/logs \
bootstrap/cache \
&& chown -R www-data:www-data . \
&& chmod -R 775 . \
&& chmod -R 775 storage bootstrap/cache
# Add entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Expose port 80
EXPOSE 80
# Switch to a non-root user for running the application
USER www-data
# Set entrypoint
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["apache2-foreground"]