-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDockerfile.amazonlinux2
71 lines (57 loc) · 2.84 KB
/
Dockerfile.amazonlinux2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
FROM amazonlinux:2
SHELL ["/bin/bash", "-c"]
# can be 7.1 or later:
ARG PHP_VERSION=7.4
# set to 1 to enable:
ARG ENABLE_IGBINARY=0
# set to 1 to enable:
ARG ENABLE_MSGPACK=0
# set to 1 to enable:
ARG ENABLE_JSON=0
RUN yum -y update \
&& yum -y install yum-utils \
&& yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
&& yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm \
&& yum-config-manager --enable remi-php`echo "$PHP_VERSION" | tr -d '.'`
RUN yum -y install php`echo "$PHP_VERSION" | tr -d '.'` php`echo "$PHP_VERSION" | tr -d '.'`-php-devel \
&& if [ $ENABLE_IGBINARY -eq 1 ]; then yum -y install php`echo "$PHP_VERSION" | tr -d '.'`-php-igbinary-devel; fi \
&& if [ $ENABLE_MSGPACK -eq 1 ]; then yum -y install php`echo "$PHP_VERSION" | tr -d '.'`-php-pecl-msgpack-devel; fi
RUN yum -y install patch make gcc gcc-c++ autoconf automake libtool
RUN echo "source scl_source enable php"`echo $PHP_VERSION | tr -d '.'` >> /root/.bash_profile
ENV BASH_ENV=/root/.bash_profile
RUN mkdir /build
COPY aws-elasticache-cluster-client-libmemcached /build/aws-elasticache-cluster-client-libmemcached
COPY aws-elasticache-cluster-client-memcached-for-php /build/aws-elasticache-cluster-client-memcached-for-php
COPY *.patch /build/
RUN cd /build/aws-elasticache-cluster-client-libmemcached \
&& for F in /build/*.patch; do patch -p1 -i "$F"; done \
&& autoreconf -i \
&& mkdir BUILD \
&& cd BUILD \
&& ../configure --prefix=/usr/local --with-pic --disable-sasl \
&& make -j`nproc` \
&& make install
RUN cd /build/aws-elasticache-cluster-client-memcached-for-php \
&& phpize \
&& ./configure \
--with-pic \
--disable-memcached-sasl \
--enable-memcached-session \
`if [ $ENABLE_JSON -eq 1 ]; then echo "--enable-memcached-json"; fi` \
`if [ $ENABLE_MSGPACK -eq 1 ]; then echo "--enable-memcached-msgpack"; fi` \
`if [ $ENABLE_IGBINARY -eq 1 ]; then echo "--enable-memcached-igbinary"; fi` \
&& sed -i "s#-lmemcachedutil#-Wl,-whole-archive /usr/local/lib/libmemcachedutil.a -Wl,-no-whole-archive#" Makefile \
&& sed -i "s#-lmemcached#-Wl,-whole-archive /usr/local/lib/libmemcached.a -Wl,-no-whole-archive#" Makefile \
&& make -j`nproc` \
&& make install
# clean slate for checks:
RUN rm -rf /build
# check that the PHP extension is statically linked to libmemcached:
RUN if ldd `find /opt/remi/ -name memcached.so` | grep memcached; then exit 1; fi
# check that the PHP extension can be loaded:
RUN php -v \
&& php -dextension=memcached.so -m | grep 'memcached' \
&& php -dextension=memcached.so -r 'new Memcached();' \
&& php -dextension=memcached.so -r 'if (!defined("Memcached::DYNAMIC_CLIENT_MODE")) exit(1);'
RUN mkdir -p /build/final \
&& cp -p `find /opt/remi/ -name memcached.so` /build/final/