Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit ea593fb

Browse files
committed
Separate runtime and library dependencies into diff layers
1 parent 2218bc9 commit ea593fb

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

Dockerfile

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,35 @@ RUN sed -i 's;^releasever.*;releasever=2017.03;;' /etc/yum.conf && \
2222
unzip \
2323
git
2424

25-
# Download the PHP 7.3.0 source, compile, and install
26-
RUN mkdir ~/php-7-bin && \
27-
curl -sL https://github.com/php/php-src/archive/php-7.3.0.tar.gz | tar -xvz && \
25+
# Download the PHP 7.3.0 source, compile, and install both PHP and Composer
26+
RUN curl -sL https://github.com/php/php-src/archive/php-7.3.0.tar.gz | tar -xvz && \
2827
cd php-src-php-7.3.0 && \
2928
./buildconf --force && \
3029
./configure --prefix=/opt/php-7-bin/ --with-openssl --with-curl --with-zlib && \
3130
make install && \
32-
/opt/php-7-bin/bin/php -v
31+
/opt/php-7-bin/bin/php -v && \
32+
curl -sS https://getcomposer.org/installer | /opt/php-7-bin/bin/php -- --install-dir=/opt/php-7-bin/bin/ --filename=composer
3333

3434
# Prepare runtime files
35-
WORKDIR /runtime
36-
RUN mkdir bin && \
37-
cp /opt/php-7-bin/bin/php bin/php
35+
RUN mkdir -p /lambda-php-runtime/bin && \
36+
cp /opt/php-7-bin/bin/php /lambda-php-runtime/bin/php
3837

39-
RUN curl -sS https://getcomposer.org/installer | ./bin/php -- --install-dir=/runtime/bin --filename=composer && \
40-
./bin/php ./bin/composer require guzzlehttp/guzzle
38+
COPY runtime/bootstrap /lambda-php-runtime/
39+
40+
# Install Guzzle, prepare vendor files
41+
RUN mkdir /lambda-php-vendor && \
42+
cd /lambda-php-vendor && \
43+
/opt/php-7-bin/bin/php /opt/php-7-bin/bin/composer require guzzlehttp/guzzle
4144

4245
###### Create runtime image ######
4346

4447
FROM lambci/lambda:provided as runtime
4548

46-
COPY --from=builder /runtime/ /opt/
49+
# Layer 1
50+
COPY --from=builder /lambda-php-runtime /opt/
4751

48-
COPY runtime/bootstrap /opt/
52+
# Layer 2
53+
COPY --from=builder /lambda-php-vendor/vendor /opt/vendor
4954

5055
###### Create function image ######
5156

0 commit comments

Comments
 (0)