Skip to content

Commit 7b6c030

Browse files
committed
Compile dependencies in parallel
1 parent 951bdff commit 7b6c030

1 file changed

Lines changed: 33 additions & 23 deletions

File tree

Dockerfile

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM composer:2.0 as step0
1+
FROM composer:2.0 as composer
22

33
ARG TESTING=false
44
ENV TESTING=$TESTING
@@ -11,46 +11,53 @@ COPY composer.json /usr/local/src/
1111
RUN composer update --ignore-platform-reqs --optimize-autoloader \
1212
--no-plugins --no-scripts --prefer-dist
1313

14-
FROM php:7.4-cli-alpine as final
15-
16-
LABEL maintainer="team@appwrite.io"
17-
18-
ENV PHP_SWOOLE_VERSION=v4.6.6
19-
ENV PHP_MONGO_VERSION=1.9.1
14+
FROM php:8.0-cli-alpine as compile
2015

2116
ENV PHP_REDIS_VERSION=5.3.4 \
22-
PHP_SWOOLE_VERSION=v4.6.7 \
23-
PHP_MONGO_VERSION=1.9.1
17+
PHP_SWOOLE_VERSION=v4.8.0 \
18+
PHP_MONGO_VERSION=1.11.1
2419

2520
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
2621

2722
RUN \
2823
apk update \
2924
&& apk add --no-cache postgresql-libs postgresql-dev make automake autoconf gcc g++ git brotli-dev \
3025
&& docker-php-ext-install opcache pgsql pdo_mysql pdo_pgsql \
31-
# Redis Extension
32-
&& git clone --depth 1 --branch $PHP_REDIS_VERSION https://github.com/phpredis/phpredis.git \
26+
&& rm -rf /var/cache/apk/*
27+
28+
# Redis Extension
29+
FROM compile AS redis
30+
RUN \
31+
git clone --depth 1 --branch $PHP_REDIS_VERSION https://github.com/phpredis/phpredis.git \
3332
&& cd phpredis \
3433
&& phpize \
3534
&& ./configure \
36-
&& make && make install \
37-
&& cd .. \
38-
## Swoole Extension
39-
&& git clone --depth 1 --branch $PHP_SWOOLE_VERSION https://github.com/swoole/swoole-src.git \
35+
&& make && make install
36+
37+
## Swoole Extension
38+
FROM compile AS swoole
39+
RUN \
40+
git clone --depth 1 --branch $PHP_SWOOLE_VERSION https://github.com/swoole/swoole-src.git \
4041
&& cd swoole-src \
4142
&& phpize \
4243
&& ./configure --enable-http2 \
43-
&& make && make install \
44-
&& cd .. \
45-
## MongoDB Extension
46-
&& git clone --depth 1 --branch $PHP_MONGO_VERSION https://github.com/mongodb/mongo-php-driver.git \
44+
&& make && make install
45+
46+
## MongoDB Extension
47+
FROM compile AS mongodb
48+
RUN \
49+
git clone --depth 1 --branch $PHP_MONGO_VERSION https://github.com/mongodb/mongo-php-driver.git \
4750
&& cd mongo-php-driver \
4851
&& git submodule update --init \
4952
&& phpize \
5053
&& ./configure \
51-
&& make && make install \
52-
&& cd .. \
53-
&& rm -rf /var/cache/apk/*
54+
&& make && make install
55+
56+
FROM php:8.0-cli-alpine as final
57+
58+
LABEL maintainer="team@appwrite.io"
59+
60+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
5461

5562
WORKDIR /usr/src/code
5663

@@ -64,7 +71,10 @@ RUN echo "opcache.enable_cli=1" >> $PHP_INI_DIR/php.ini
6471

6572
RUN echo "memory_limit=1024M" >> $PHP_INI_DIR/php.ini
6673

67-
COPY --from=step0 /usr/local/src/vendor /usr/src/code/vendor
74+
COPY --from=composer /usr/local/src/vendor /usr/src/code/vendor
75+
COPY --from=swoole /usr/local/lib/php/extensions/no-debug-non-zts-20200930/swoole.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/yasd.so* /usr/local/lib/php/extensions/no-debug-non-zts-20200930/
76+
COPY --from=redis /usr/local/lib/php/extensions/no-debug-non-zts-20200930/redis.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/
77+
COPY --from=mongodb /usr/local/lib/php/extensions/no-debug-non-zts-20200930/mongodb.so /usr/local/lib/php/extensions/no-debug-non-zts-20200930/
6878

6979
# Add Source Code
7080
COPY . /usr/src/code

0 commit comments

Comments
 (0)