Skip to content

Commit 6388cc3

Browse files
authored
Merge pull request #133 from WyriHaximusNet/introduce-base-states-for-shared-setup-runs
Introduce base stages for shared setup runs
2 parents 1034246 + 2a6b77e commit 6388cc3

4 files changed

Lines changed: 93 additions & 96 deletions

File tree

Dockerfile-nts-alpine

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
# syntax=docker/dockerfile:experimental
2-
FROM php:7.4-cli-alpine3.11 AS build-uv
3-
RUN apk update && \
4-
apk add --no-cache $PHPIZE_DEPS git libuv-dev && \
5-
git clone https://github.com/bwoebi/php-uv uv
6-
WORKDIR /uv
7-
RUN git fetch \
8-
&& git pull \
9-
&& phpize \
10-
&& ./configure \
11-
&& make install \
12-
&& EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
13-
cp "$EXTENSION_DIR/uv.so" /uv.so
14-
RUN sha256sum /uv.so
15-
16-
FROM php:7.4-cli-alpine3.11 AS nts-slim-root
2+
FROM php:7.4-cli-alpine3.11 AS base
173

184
# Build-time metadata as defined at http://label-schema.org
195
LABEL org.label-schema.name="wyrihaximusnet/php" \
@@ -23,10 +9,29 @@ LABEL org.label-schema.name="wyrihaximusnet/php" \
239
org.label-schema.vendor="WyriHaximus.net" \
2410
org.label-schema.schema-version="1.0"
2511

26-
RUN set -x \
12+
RUN apk update \
13+
&& set -x \
2714
&& addgroup -g 1000 app \
2815
&& adduser -u 1000 -D -G app app \
2916
&& touch /.you-are-in-a-wyrihaximus.net-php-docker-image
17+
18+
FROM base AS base-build
19+
RUN apk add --no-cache $PHPIZE_DEPS git libuv-dev
20+
21+
FROM base-build AS build-uv
22+
RUN git clone https://github.com/bwoebi/php-uv uv
23+
WORKDIR /uv
24+
RUN git fetch \
25+
&& git pull \
26+
&& phpize \
27+
&& ./configure \
28+
&& make install \
29+
&& EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
30+
cp "$EXTENSION_DIR/uv.so" /uv.so
31+
RUN sha256sum /uv.so
32+
33+
FROM base AS nts-slim-root
34+
3035
COPY --from=build-uv /uv.so /uv.so
3136

3237
# Patch CVE-2018-14618 (curl), CVE-2018-16842 (libxml2), CVE-2019-1543 (openssl)
@@ -40,7 +45,6 @@ COPY src/php/cli/conf/*.ini /usr/local/etc/php/conf.d/
4045

4146
RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
4247
mv /*.so "$EXTENSION_DIR/" && \
43-
apk update && \
4448
apk add --no-cache \
4549
gmp-dev \
4650
zlib-dev \

Dockerfile-nts-debian

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
# syntax=docker/dockerfile:experimental
2-
FROM php:7.4-cli-buster AS build-uv
3-
RUN apt-get update && \
4-
yes | apt-get install $PHPIZE_DEPS git libuv1-dev && \
5-
git clone https://github.com/bwoebi/php-uv uv
6-
WORKDIR /uv
7-
RUN git fetch \
8-
&& git pull \
9-
&& phpize \
10-
&& ./configure \
11-
&& make install \
12-
&& EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
13-
cp "$EXTENSION_DIR/uv.so" /uv.so
14-
RUN sha256sum /uv.so
15-
16-
FROM php:7.4-cli-buster AS nts-slim-root
2+
FROM php:7.4-cli-buster AS base
173

184
# Build-time metadata as defined at http://label-schema.org
19-
ARG BUILD_DATE
20-
ARG VCS_REF
21-
LABEL org.label-schema.build-date=$BUILD_DATE \
22-
org.label-schema.name="wyrihaximusnet/php" \
5+
LABEL org.label-schema.name="wyrihaximusnet/php" \
236
org.label-schema.description="Opinionated ReactPHP optimised PHP Docker images" \
247
org.label-schema.url="https://github.com/wyrihaximusnet/docker-php" \
25-
org.label-schema.vcs-ref=$VCS_REF \
268
org.label-schema.vcs-url="https://github.com/wyrihaximusnet/docker-php" \
279
org.label-schema.vendor="WyriHaximus.net" \
2810
org.label-schema.schema-version="1.0"
2911

30-
RUN set -x \
12+
RUN apt-get update \
13+
&& yes | apt-get upgrade \
14+
&& set -x \
3115
&& addgroup --gid 1000 app \
3216
&& adduser --uid 1000 --gid 1000 --disabled-password app \
3317
&& touch /.you-are-in-a-wyrihaximus.net-php-docker-image
3418

19+
FROM base AS base-build
20+
RUN yes | apt-get install $PHPIZE_DEPS git libuv1-dev
21+
22+
FROM base-build AS build-uv
23+
RUN git clone https://github.com/bwoebi/php-uv uv
24+
WORKDIR /uv
25+
RUN git fetch \
26+
&& git pull \
27+
&& phpize \
28+
&& ./configure \
29+
&& make install \
30+
&& EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
31+
cp "$EXTENSION_DIR/uv.so" /uv.so
32+
RUN sha256sum /uv.so
33+
34+
FROM base AS nts-slim-root
35+
3536
COPY --from=build-uv /uv.so /uv.so
3637

3738
# Patch CVE-2018-14618 (curl), CVE-2018-16842 (libxml2), CVE-2019-1543 (openssl)
38-
RUN apt-get update && \
39-
yes | apt-get upgrade curl libxml2 openssl
39+
RUN yes | apt-get upgrade curl libxml2 openssl
4040

4141
# Install docker help scripts
4242
COPY src/php/utils/docker/debian/ /usr/local/bin/
@@ -46,8 +46,6 @@ COPY src/php/cli/conf/*.ini /usr/local/etc/php/conf.d/
4646

4747
RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
4848
mv /*.so "$EXTENSION_DIR/" && \
49-
apt-get update && \
50-
yes | apt-get upgrade && \
5149
yes | apt-get install \
5250
libgmp-dev \
5351
zlib1g-dev \
@@ -100,8 +98,7 @@ RUN dev-mode && rm -rf /usr/local/bin/dev-mode && rm -rf /usr/local/bin/docker-p
10098

10199
# Install composer
102100
COPY src/php/utils/install-composer /usr/local/bin/
103-
RUN apt-get update \
104-
&& yes | apt-get install wget unzip \
101+
RUN yes | apt-get install wget unzip \
105102
&& install-composer \
106103
&& yes | apt-get purge wget \
107104
&& yes | apt-get install make \
@@ -122,8 +119,7 @@ RUN dev-mode && rm -rf /usr/local/bin/dev-mode && rm -rf /usr/local/bin/docker-p
122119

123120
# Install composer
124121
COPY src/php/utils/install-composer /usr/local/bin/
125-
RUN apt-get update \
126-
&& yes | apt-get install wget unzip \
122+
RUN yes | apt-get install wget unzip \
127123
&& install-composer \
128124
&& yes | apt-get purge wget \
129125
&& yes | apt-get install make \

Dockerfile-zts-alpine

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
# syntax=docker/dockerfile:experimental
2-
FROM php:7.4-zts-alpine3.11 AS build-uv
3-
RUN apk update && \
4-
apk add --no-cache $PHPIZE_DEPS git libuv-dev && \
5-
git clone https://github.com/bwoebi/php-uv uv
6-
WORKDIR /uv
7-
RUN git fetch \
8-
&& git pull \
9-
&& phpize \
10-
&& ./configure \
11-
&& make install \
12-
&& EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
13-
cp "$EXTENSION_DIR/uv.so" /uv.so
14-
RUN sha256sum /uv.so
15-
16-
FROM php:7.4-zts-alpine3.11 AS zts-slim-root
2+
FROM php:7.4-zts-alpine3.11 AS base
173

184
# Build-time metadata as defined at http://label-schema.org
195
LABEL org.label-schema.name="wyrihaximusnet/php" \
@@ -23,11 +9,29 @@ LABEL org.label-schema.name="wyrihaximusnet/php" \
239
org.label-schema.vendor="WyriHaximus.net" \
2410
org.label-schema.schema-version="1.0"
2511

26-
RUN set -x \
12+
RUN apk update \
13+
&& set -x \
2714
&& addgroup -g 1000 app \
2815
&& adduser -u 1000 -D -G app app \
2916
&& touch /.you-are-in-a-wyrihaximus.net-php-docker-image
3017

18+
FROM base AS base-build
19+
RUN apk add --no-cache $PHPIZE_DEPS git libuv-dev
20+
21+
FROM base-build AS build-uv
22+
RUN git clone https://github.com/bwoebi/php-uv uv
23+
WORKDIR /uv
24+
RUN git fetch \
25+
&& git pull \
26+
&& phpize \
27+
&& ./configure \
28+
&& make install \
29+
&& EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
30+
cp "$EXTENSION_DIR/uv.so" /uv.so
31+
RUN sha256sum /uv.so
32+
33+
FROM base AS zts-slim-root
34+
3135
COPY --from=build-uv /uv.so /uv.so
3236

3337
# Patch CVE-2018-14618 (curl), CVE-2018-16842 (libxml2), CVE-2019-1543 (openssl)
@@ -41,7 +45,6 @@ COPY src/php/cli/conf/*.ini /usr/local/etc/php/conf.d/
4145

4246
RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
4347
mv /*.so "$EXTENSION_DIR/" && \
44-
apk update && \
4548
apk add --no-cache \
4649
gmp-dev \
4750
zlib-dev \

Dockerfile-zts-debian

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
# syntax=docker/dockerfile:experimental
2-
FROM php:7.4-zts-buster AS build-parallel
3-
RUN apt-get update && \
4-
yes | apt-get install $PHPIZE_DEPS git
2+
FROM php:7.4-zts-buster AS base
3+
4+
# Build-time metadata as defined at http://label-schema.org
5+
LABEL org.label-schema.name="wyrihaximusnet/php" \
6+
org.label-schema.description="Opinionated ReactPHP optimised PHP Docker images" \
7+
org.label-schema.url="https://github.com/wyrihaximusnet/docker-php" \
8+
org.label-schema.vcs-url="https://github.com/wyrihaximusnet/docker-php" \
9+
org.label-schema.vendor="WyriHaximus.net" \
10+
org.label-schema.schema-version="1.0"
11+
12+
RUN apt-get update \
13+
&& yes | apt-get upgrade \
14+
&& set -x \
15+
&& addgroup --gid 1000 app \
16+
&& adduser --uid 1000 --gid 1000 --disabled-password app \
17+
&& touch /.you-are-in-a-wyrihaximus.net-php-docker-image
18+
19+
FROM base AS base-build
20+
RUN yes | apt-get install $PHPIZE_DEPS git libuv1-dev
21+
22+
FROM base-build AS build-parallel
523
RUN git clone https://github.com/krakjoe/parallel
624
WORKDIR /parallel
725
RUN git fetch \
@@ -13,10 +31,8 @@ RUN git fetch \
1331
cp "$EXTENSION_DIR/parallel.so" /parallel.so
1432
RUN sha256sum /parallel.so
1533

16-
FROM php:7.4-zts-buster AS build-uv
17-
RUN apt-get update && \
18-
yes | apt-get install $PHPIZE_DEPS git libuv1-dev && \
19-
git clone https://github.com/bwoebi/php-uv uv
34+
FROM base-build AS build-uv
35+
RUN git clone https://github.com/bwoebi/php-uv uv
2036
WORKDIR /uv
2137
RUN git fetch \
2238
&& git pull \
@@ -27,31 +43,13 @@ RUN git fetch \
2743
cp "$EXTENSION_DIR/uv.so" /uv.so
2844
RUN sha256sum /uv.so
2945

30-
FROM php:7.4-zts-buster AS zts-slim-root
31-
32-
# Build-time metadata as defined at http://label-schema.org
33-
ARG BUILD_DATE
34-
ARG VCS_REF
35-
LABEL org.label-schema.build-date=$BUILD_DATE \
36-
org.label-schema.name="wyrihaximusnet/php" \
37-
org.label-schema.description="Opinionated ReactPHP optimised PHP Docker images" \
38-
org.label-schema.url="https://github.com/wyrihaximusnet/docker-php" \
39-
org.label-schema.vcs-ref=$VCS_REF \
40-
org.label-schema.vcs-url="https://github.com/wyrihaximusnet/docker-php" \
41-
org.label-schema.vendor="WyriHaximus.net" \
42-
org.label-schema.schema-version="1.0"
43-
44-
RUN set -x \
45-
&& addgroup --gid 1000 app \
46-
&& adduser --uid 1000 --gid 1000 --disabled-password app \
47-
&& touch /.you-are-in-a-wyrihaximus.net-php-docker-image
46+
FROM base AS zts-slim-root
4847

4948
COPY --from=build-parallel /parallel.so /parallel.so
5049
COPY --from=build-uv /uv.so /uv.so
5150

5251
# Patch CVE-2018-14618 (curl), CVE-2018-16842 (libxml2), CVE-2019-1543 (openssl)
53-
RUN apt-get update && \
54-
yes | apt-get upgrade curl libxml2 openssl
52+
RUN yes | apt-get upgrade curl libxml2 openssl
5553

5654
# Install docker help scripts
5755
COPY src/php/utils/docker/debian/ /usr/local/bin/
@@ -61,8 +59,6 @@ COPY src/php/cli/conf/*.ini /usr/local/etc/php/conf.d/
6159

6260
RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
6361
mv /*.so "$EXTENSION_DIR/" && \
64-
apt-get update && \
65-
yes | apt-get upgrade && \
6662
yes | apt-get install \
6763
libgmp-dev \
6864
zlib1g-dev \
@@ -116,8 +112,7 @@ RUN dev-mode && rm -rf /usr/local/bin/dev-mode && rm -rf /usr/local/bin/docker-p
116112

117113
# Install composer
118114
COPY src/php/utils/install-composer /usr/local/bin/
119-
RUN apt-get update \
120-
&& yes | apt-get install wget unzip \
115+
RUN yes | apt-get install wget unzip \
121116
&& install-composer \
122117
&& yes | apt-get purge wget \
123118
&& yes | apt-get install make \
@@ -138,8 +133,7 @@ RUN dev-mode && rm -rf /usr/local/bin/dev-mode && rm -rf /usr/local/bin/docker-p
138133

139134
# Install composer
140135
COPY src/php/utils/install-composer /usr/local/bin/
141-
RUN apt-get update \
142-
&& yes | apt-get install wget unzip \
136+
RUN yes | apt-get install wget unzip \
143137
&& install-composer \
144138
&& yes | apt-get purge wget \
145139
&& yes | apt-get install make \

0 commit comments

Comments
 (0)