|
1 | | -# FROM php:7.4.33-cli-alpine |
2 | | -# FROM php:8.1.28-cli-alpine |
3 | | -#FROM php:8.2.18-cli-alpine |
4 | 1 | FROM php:8.4.16-cli-alpine |
5 | 2 |
|
6 | 3 | LABEL Maintainer="ShaoBo Wan (Tinywan) <756684177@qq.com>" \ |
7 | 4 | Description="Webman Lightweight container with PHP 8.4.16 based on Alpine Linux." |
8 | 5 |
|
9 | | -# Container package : mirrors.163.com、mirrors.aliyun.com、mirrors.ustc.edu.cn |
| 6 | +# Use Alibaba Cloud mirror for faster downloads |
10 | 7 | RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories |
11 | | -# RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g" /etc/apk/repositories |
12 | 8 |
|
13 | | -RUN cat /etc/issue |
14 | | - |
15 | | -# [php74] Add basics first |
16 | | -# RUN apk update && apk add bash curl ca-certificates openssl openssh git libxml2-dev tzdata icu-dev openntpd libedit-dev libzip-dev libjpeg-turbo-dev libpng-dev freetype-dev autoconf dpkg-dev dpkg file g++ gcc libc-dev make pkgconf re2c pcre-dev libffi-dev libressl-dev libevent-dev zlib-dev libtool automake supervisor |
17 | | - |
18 | | -# [php8] Add basics first |
19 | | -RUN apk update && apk add bash curl ca-certificates openssl openssh git nano libxml2-dev tzdata icu-dev openntpd libedit-dev libzip-dev libjpeg-turbo-dev libpng-dev freetype-dev autoconf file g++ gcc libc-dev make pkgconf re2c pcre-dev openssl-dev libffi-dev libevent-dev zlib-dev libtool automake supervisor |
| 9 | +# Install runtime dependencies only (build deps will be installed and removed later) |
| 10 | +RUN apk add --no-cache curl ca-certificates tzdata supervisor |
20 | 11 |
|
21 | 12 | COPY ./extension /tmp/extension |
22 | 13 | WORKDIR /tmp/extension |
23 | | -RUN sed -i 's/\r$//' install.sh \ |
24 | | - && chmod +x install.sh \ |
25 | | - && sh install.sh \ |
26 | | - && rm -rf /tmp/extension |
27 | 14 |
|
28 | | -RUN php -m |
| 15 | +# Install build dependencies, compile extensions, then cleanup everything in one layer |
| 16 | +RUN apk add --no-cache --virtual .build-deps \ |
| 17 | + libxml2-dev libzip-dev libjpeg-turbo-dev libpng-dev freetype-dev \ |
| 18 | + libevent-dev openssl-dev libffi-dev icu-dev bzip2-dev postgresql-dev \ |
| 19 | + autoconf g++ gcc make libc-dev pkgconf re2c libtool automake \ |
| 20 | + && sed -i 's/\r$//' install.sh \ |
| 21 | + && sh install.sh \ |
| 22 | + && rm -rf /tmp/extension \ |
| 23 | + && apk del .build-deps \ |
| 24 | + && rm -rf /var/cache/apk/* /tmp/* /root/.pearrc /usr/local/include/php |
29 | 25 |
|
30 | | -# Add Composer |
31 | | -RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer |
| 26 | +# Add Composer (with cache cleanup) |
| 27 | +RUN curl -sS https://getcomposer.org/installer | php \ |
| 28 | + && mv composer.phar /usr/local/bin/composer \ |
| 29 | + && rm -rf /root/.composer/cache |
32 | 30 |
|
33 | 31 | # Configure PHP |
34 | 32 | COPY config/php.ini /usr/local/etc/php/conf.d/zzz_custom.ini |
35 | 33 |
|
36 | 34 | # Configure supervisord |
37 | 35 | COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf |
38 | 36 |
|
39 | | -# Make sure files/folders needed by the processes are accessable when they run under the nobody user |
40 | | -# RUN chown -R nobody.nobody /run |
41 | | - |
42 | 37 | # Setup document root |
43 | 38 | RUN mkdir -p /app |
44 | 39 |
|
45 | | -# Make the document root a volume |
46 | 40 | VOLUME /app |
47 | | - |
48 | | -#echo " > /usr/local/etc/php/conf.d/phalcon.ini |
49 | | -# Switch to use a non-root user from here on |
50 | | -USER root |
51 | | - |
52 | | -# Add application |
53 | 41 | WORKDIR /app |
54 | | - |
55 | | -# Expose the port nginx is reachable on |
56 | 42 | EXPOSE 8787 |
57 | 43 |
|
58 | | -# Let supervisord start nginx & php |
59 | 44 | CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] |
0 commit comments