-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
82 lines (62 loc) · 1.84 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
# Install PHP libraries
FROM composer:2.0 as composer
WORKDIR /usr/local/src/
COPY composer.lock /usr/local/src/
COPY composer.json /usr/local/src/
RUN composer install --ignore-platform-reqs --optimize-autoloader \
--no-plugins --no-scripts --prefer-dist
# Prepare generic compiler
FROM php:8.3.7-cli-alpine3.19 as compile
ENV PHP_SWOOLE_VERSION=v5.1.2
RUN \
apk add --no-cache --virtual .deps \
make \
automake \
autoconf \
gcc \
g++ \
git \
linux-headers \
openssl-dev \
curl-dev
RUN docker-php-ext-install sockets
# Compile Swoole
FROM compile AS swoole
RUN \
git clone --depth 1 --branch $PHP_SWOOLE_VERSION https://github.com/swoole/swoole-src.git && \
cd swoole-src && \
phpize && \
./configure --enable-sockets --enable-http2 --enable-openssl --enable-swoole-curl && \
make && make install && \
cd ..
# Proxy
FROM php:8.3.7-cli-alpine3.19 as final
ARG OPR_PROXY_VERSION
ENV OPR_PROXY_VERSION=$OPR_PROXY_VERSION
LABEL maintainer="[email protected]"
RUN \
apk update \
&& apk add --no-cache --virtual .deps \
make \
automake \
autoconf \
curl-dev \
gcc \
g++ \
linux-headers \
&& apk add --no-cache \
libstdc++ \
&& docker-php-ext-install sockets \
&& apk del .deps \
&& rm -rf /var/cache/apk/*
WORKDIR /usr/local/
# Source code
COPY ./app /usr/local/app
COPY ./src /usr/local/src
# Extensions and libraries
COPY --from=composer /usr/local/src/vendor /usr/local/vendor
COPY --from=swoole /usr/local/lib/php/extensions/no-debug-non-zts-20230831/swoole.so /usr/local/lib/php/extensions/no-debug-non-zts-20230831/
RUN echo extension=swoole.so >> /usr/local/etc/php/conf.d/swoole.ini
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=15s --start-period=60s --retries=3 CMD curl -s -H "Authorization: Bearer ${OPR_PROXY_SECRET}" --fail http://127.0.0.1:80/v1/proxy/health
CMD [ "php", "app/http.php" ]