Skip to content

Switch to the multi-stage build pattern #99

@dkarlovi

Description

@dkarlovi

Looking at the Dockerfile and the image's history (see below), it seems we can save quite a bit of space by switching to the multi-stage build pattern.

It should allow us to avoid having a 250MB+ intermediate layer in the image:

$ docker history jakzal/phpqa:alpine 
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
76b1555a30f9        19 hours ago        /bin/sh -c #(nop)  CMD ["/bin/sh" "-c" "php …   0B                  
<missing>           19 hours ago        /bin/sh -c apk add --no-cache --virtual .too…   252MB               
<missing>           19 hours ago        /bin/sh -c #(nop) COPY file:60fad6cf4445b0d0…   1.88MB              
<missing>           19 hours ago        /bin/sh -c #(nop) COPY file:287ae7377cdad1b1…   23.6kB              
<missing>           19 hours ago        /bin/sh -c #(nop) COPY file:850923d8354d1f73…   18.7kB              
<missing>           19 hours ago        /bin/sh -c #(nop)  ENV TOOLS_JSON=/tools/too…   0B                  
<missing>           19 hours ago        /bin/sh -c #(nop)  ENV PATH=/usr/local/sbin:…   0B                  
<missing>           19 hours ago        /bin/sh -c #(nop)  ENV TOOL_DEPS=git graphvi…   0B                  
<missing>           19 hours ago        /bin/sh -c #(nop)  ENV LIB_DEPS=zlib-dev        0B                  
<missing>           19 hours ago        /bin/sh -c #(nop)  ENV BUILD_DEPS=autoconf f…   0B                  
<missing>           19 hours ago        /bin/sh -c #(nop)  ENV COMPOSER_HOME=/tools/…   0B                  
<missing>           19 hours ago        /bin/sh -c #(nop)  ENV COMPOSER_ALLOW_SUPERU…   0B                  
<missing>           19 hours ago        /bin/sh -c #(nop)  LABEL maintainer=Jakub Za…   0B                  
<missing>           2 weeks ago         /bin/sh -c #(nop)  CMD ["php" "-a"]             0B                  
<missing>           2 weeks ago         /bin/sh -c #(nop)  ENTRYPOINT ["docker-php-e…   0B                  
<missing>           2 weeks ago         /bin/sh -c docker-php-ext-enable sodium         168kB               
<missing>           2 weeks ago         /bin/sh -c #(nop) COPY multi:2cdcedabcf5a3b9…   6.42kB              
<missing>           2 weeks ago         /bin/sh -c set -xe  && apk add --no-cache --…   58.1MB              
<missing>           2 weeks ago         /bin/sh -c #(nop) COPY file:207c686e3fed4f71…   587B                
<missing>           2 weeks ago         /bin/sh -c set -xe;   apk add --no-cache --v…   12.2MB              
<missing>           2 weeks ago         /bin/sh -c #(nop)  ENV PHP_SHA256=da1a705c0b…   0B                  
<missing>           2 weeks ago         /bin/sh -c #(nop)  ENV PHP_URL=https://secur…   0B                  
<missing>           2 weeks ago         /bin/sh -c #(nop)  ENV PHP_VERSION=7.2.11       0B                  
<missing>           6 weeks ago         /bin/sh -c #(nop)  ENV GPG_KEYS=1729F83938DA…   0B                  
<missing>           6 weeks ago         /bin/sh -c #(nop)  ENV PHP_LDFLAGS=-Wl,-O1 -…   0B                  
<missing>           6 weeks ago         /bin/sh -c #(nop)  ENV PHP_CPPFLAGS=-fstack-…   0B                  
<missing>           6 weeks ago         /bin/sh -c #(nop)  ENV PHP_CFLAGS=-fstack-pr…   0B                  
<missing>           6 weeks ago         /bin/sh -c mkdir -p $PHP_INI_DIR/conf.d         0B                  
<missing>           6 weeks ago         /bin/sh -c #(nop)  ENV PHP_INI_DIR=/usr/loca…   0B                  
<missing>           6 weeks ago         /bin/sh -c set -x  && addgroup -g 82 -S www-…   4.85kB              
<missing>           6 weeks ago         /bin/sh -c apk add --no-cache --virtual .per…   2.69MB              
<missing>           6 weeks ago         /bin/sh -c #(nop)  ENV PHPIZE_DEPS=autoconf …   0B                  
<missing>           6 weeks ago         /bin/sh -c #(nop)  CMD ["/bin/sh"]              0B                  
<missing>           6 weeks ago         /bin/sh -c #(nop) ADD file:25c10b1d1b41d46a1…   4.41MB   

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions