-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
81 lines (68 loc) · 2.08 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
71
72
73
74
75
76
77
78
79
80
81
FROM node:21-alpine3.18 AS frontend-build
WORKDIR /front-code
COPY package.json package-lock.json /front-code/
RUN npm install
COPY ./resources /front-code/resources
RUN npm run portal:build
RUN npm run site:build
FROM alpine:3.19
WORKDIR /var/www/html
# Install packages and remove default server definition
RUN apk add --no-cache \
curl \
nginx \
php83 \
php83-common \
php83-ctype \
php83-curl \
php83-dom \
php83-fpm \
php83-gd \
php83-intl \
php83-mbstring \
php83-mysqli \
php83-opcache \
php83-openssl \
php83-phar \
php83-session \
php83-xml \
php83-xmlreader \
php83-xmlwriter \
php83-simplexml \
php83-pdo_pgsql \
php83-zip \
php83-tokenizer \
php83-fileinfo \
supervisor
# Create symlink so programs depending on `php` still function
RUN ln -s /usr/bin/php83 /usr/bin/php
# Configure nginx
COPY docker/nginx.conf /etc/nginx/nginx.conf
# Configure PHP-FPM
COPY docker/fpm-pool.conf /etc/php83/php-fpm.d/www.conf
COPY docker/php.ini /etc/php83/conf.d/custom.ini
# Configure supervisord
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Make sure files/folders needed by the processes are accessable when they run under the nobody user
RUN chown -R nobody.nobody /var/www/html /run /var/lib/nginx /var/log/nginx
# Switch to use a non-root user from here on
USER nobody
# Install composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# Add application
COPY composer.json composer.lock /var/www/html/
RUN composer install --no-dev --no-scripts
COPY --chown=nobody ./ /var/www/html/
RUN mkdir -p /var/www/html/storage/app/public
COPY --from=frontend-build /front-code/public/portal/ /var/www/html/public/portal
COPY --from=frontend-build /front-code/public/site/ /var/www/html/public/site
RUN composer dump-autoload
# After deployment scripts
RUN chmod -R 775 storage
RUN php artisan config:cache
RUN php artisan route:cache
RUN php artisan view:cache
RUN php artisan optimize
RUN php artisan storage:link
# Let supervisord start nginx & php-fpm
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]