fix(Image):手动编译event扩展

This commit is contained in:
Yu Sun
2022-09-28 18:49:07 +08:00
parent cec792f425
commit 8b878b603a
2 changed files with 60 additions and 24 deletions

View File

@@ -1,28 +1,61 @@
FROM alpine:latest
FROM alpine:3.15
ENV TZ=Asia/Shanghai
RUN echo 'https://mirrors.ustc.edu.cn/alpine/latest-stable/main/' > /etc/apk/repositories \
&& echo 'https://mirrors.ustc.edu.cn/alpine/latest-stable/community/' >> /etc/apk/repositories \
&& apk update \
&& apk add alpine-conf \
&& /sbin/setup-timezone -z $TZ \
&& apk del alpine-conf
ADD https://php.hernandev.com/key/php-alpine.rsa.pub /etc/apk/keys/php-alpine.rsa.pub
RUN apk --no-cache add php81 \
php81-posix \
php81-pcntl \
php81-pgsql \
php81-openssl \
php81-mbstring \
php81-curl \
php81-phar \
php81-pecl-event \
&& ln -s /usr/bin/php81 /usr/local/bin/php
RUN apk add ca-certificates \
&& echo -e '\
https://mirrors.ustc.edu.cn/alpine/latest-stable/main\n\
https://mirrors.ustc.edu.cn/alpine/latest-stable/community\n\
https://php.hernandev.com/v3.15/php-8.1\
' > /etc/apk/repositories \
&& apk update \
&& apk add \
tzdata \
php \
php-pgsql \
# event扩展运行时需要
php-sockets \
# 以下两件为workerman运行时需要
# https://github.com/walkor/workerman/issues/8
php-posix \
php-pcntl \
# 安装event扩展需要pecl
php-pear \
# 提供phpize
php-dev \
# 编译event扩展需要
autoconf \
# 以下两件足以在alpine里提供一般C编译环境
# g++则会提供gcc、musl-dev、libc-dev和g++,有点冗余
gcc \
musl-dev \
libevent-dev \
make \
composer \
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone \
&& ln -s /usr/bin/php8 /usr/bin/php
RUN apk --no-cache add curl \
&& curl -s https://mirrors.aliyun.com/composer/composer.phar -o /usr/local/bin/composer \
&& chmod +x /usr/local/bin/composer \
&& composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ \
&& apk del curl
RUN printf "\n\n\n\n\nno\nyes\n\n" | pecl install event \
&& echo "extension=event.so" > /etc/php8/conf.d/02_event.ini
WORKDIR /EdgeManager
COPY . /EdgeManager
WORKDIR /EdgeManager
RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ \
&& composer u --no-cache
RUN apk del \
tzdata \
composer \
ca-certificates \
php-pear \
php-dev \
autoconf \
gcc \
musl-dev \
make \
&& rm -rf /var/cache/apk/* \
/etc/apk/keys/php-alpine.rsa.pub \
/tmp/*