Docker多阶构建

Dockerfile

1
FROM alpine:3.9.6 as build
2
3
# 构建xlswriter扩展,根据自身需要替换版本号
4
ENV XLSWRITER_VERSION 1.3.4.1
5
6
RUN apk update \
7
&& apk add --no-cache php7-pear php7-dev zlib-dev re2c gcc g++ make curl \
8
&& curl -fsSL "https://pecl.php.net/get/xlswriter-${XLSWRITER_VERSION}.tgz" -o xlswriter.tgz \
9
&& mkdir -p /tmp/xlswriter \
10
&& tar -xf xlswriter.tgz -C /tmp/xlswriter --strip-components=1 \
11
&& rm xlswriter.tgz \
12
&& cd /tmp/xlswriter \
13
&& phpize && ./configure --enable-reader && make && make install
14
15
#-------------------------------------------------------------------------------------------
16
17
FROM alpine:3.9.6
18
19
# 根据自身需要,添加其它软件
20
RUN apk update && apk add --no-cache php
21
22
COPY --from=build /usr/lib/php7/modules/xlswriter.so /usr/lib/php7/modules/xlswriter.so
23
24
RUN echo "extension=xlswriter.so" > /etc/php7/conf.d/xlswriter.ini
Copied!

构建

1
docker build -f Dockerfile -t viest/xlswriter:1.3.4.1 .
Copied!
Last modified 1yr ago
Copy link