-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
89 lines (73 loc) · 2.36 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
82
83
84
85
86
87
88
89
# Install Caddy
FROM docker.io/caddy:builder-alpine AS caddy-builder
ENV GO111MODULE=on \
GOPROXY=https://goproxy.cn,direct
RUN xcaddy build
# Install PHP
FROM docker.io/alpine:3.20.3
# Setup document root
WORKDIR /var/www/html
# Get caddy
COPY --from=caddy-builder /usr/bin/caddy /usr/bin/caddy
# Install packages and remove default server definition
RUN apk add --no-cache \
curl \
php83 \
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-zlib \
php83-redis \
php83-tokenizer \
php83-fileinfo \
php83-zip \
php83-pdo \
php83-pdo_mysql \
php83-pdo_pgsql \
php83-exif \
php83-pecl-xdebug \
php83-xmlwriter \
php83-simplexml \
php83-iconv \
php83-bcmath \
supervisor \
icu-data-full
# Create symlink so programs depending on `php` still function
RUN ln -s /usr/bin/php83 /usr/bin/php
# Install composer
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php && \
php -r "unlink('composer-setup.php');" && \
mv composer.phar /usr/local/bin/composer
# Configure nginx
COPY config/Caddyfile /etc/caddy/Caddyfile
# Configure PHP-FPM
COPY config/fpm-pool.conf /etc/php83/php-fpm.d/www.conf
COPY config/php.ini /etc/php83/conf.d/custom.ini
# Configure supervisord
COPY config/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 mkdir /.config
RUN chown -R nobody.nobody /var/www/html /run /.config
# Switch to use a non-root user from here on
USER nobody
# Add application
COPY --chown=nobody src/ /var/www/html/
# Expose the port nginx is reachable on
EXPOSE 8080
# Let supervisord start nginx & php-fpm
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
# Configure a healthcheck to validate that everything is up&running
HEALTHCHECK --timeout=10s CMD curl --silent --fail http://127.0.0.1:8080/fpm-ping