forked from Akhu/simple-http-server-student-playground
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
50 lines (35 loc) · 1.34 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
# Stage 1: Composer
FROM composer:2 as composer
WORKDIR /app
COPY ./ /app
RUN composer install \
--optimize-autoloader \
--ignore-platform-reqs \
--no-interaction \
--no-plugins \
--no-scripts \
--prefer-dist
# Stage 2: PHP and Nginx
FROM php:8.2-fpm
# Install Nginx and supervisord from Debian repository
RUN apt-get update && apt-get install -y nginx supervisor && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=composer /app /app
RUN docker-php-ext-install pdo_mysql
COPY . .
RUN chown -R www-data:www-data \
/app/storage \
/app/bootstrap/cache
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
RUN php artisan key:generate
# Supervisor configuration
RUN echo "[supervisord]" > /etc/supervisor/conf.d/supervisord.conf \
&& echo "nodaemon=true" >> /etc/supervisor/conf.d/supervisord.conf \
&& echo "" >> /etc/supervisor/conf.d/supervisord.conf \
&& echo "[program:php-fpm]" >> /etc/supervisor/conf.d/supervisord.conf \
&& echo "command=php-fpm" >> /etc/supervisor/conf.d/supervisord.conf \
&& echo "" >> /etc/supervisor/conf.d/supervisord.conf \
&& echo "[program:nginx]" >> /etc/supervisor/conf.d/supervisord.conf \
&& echo "command=nginx -g 'daemon off;'" >> /etc/supervisor/conf.d/supervisord.conf
EXPOSE 80
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]