Skip to content

Commit

Permalink
Add memcache extension layer (brefphp#5)
Browse files Browse the repository at this point in the history
* add memcache extension

* include patch file

* Make sure we install memcached too

Co-authored-by: Tobias Nyholm <[email protected]>
  • Loading branch information
Jens Schulze and Nyholm committed Dec 30, 2019
1 parent 53d807b commit c8b6b84
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ layers: docker-images

publish: layers
php ./bref-extra publish
php ./bref-extra list
php ./bref-extra list
54 changes: 54 additions & 0 deletions layers/memcached/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
ARG PHP_VERSION
FROM bref/build-php-$PHP_VERSION as ext

ENV LIBMEMCACHED_BUILD_DIR=${BUILD_DIR}/libmemcached

RUN set -xe; \
mkdir -p ${LIBMEMCACHED_BUILD_DIR}; \
# Download and upack the source code
curl -Ls https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz \
| tar xzC ${LIBMEMCACHED_BUILD_DIR}

# patch from https://src.fedoraproject.org/rpms/libmemcached/raw/HEAD/f/libmemcached-build.patch for build with GCC7
COPY libmemcached-build.patch ${LIBMEMCACHED_BUILD_DIR}/libmemcached-1.0.18/libmemcached-build.patch

# Move into the unpackaged code directory
WORKDIR ${LIBMEMCACHED_BUILD_DIR}/libmemcached-1.0.18/

# Install
RUN set -xe; \
patch -d . -p0 < libmemcached-build.patch && \
./configure --prefix=${INSTALL_DIR} && \
make && \
make install

RUN pecl install memcache
RUN cp /opt/bref/lib/php/extensions/no-debug-zts-*/memcache.so /tmp/memcache.so

RUN pecl install --onlyreqdeps --nobuild memcached && \
cd "$(pecl config-get temp_dir)/memcached" && \
phpize && \
./configure --with-libmemcached-dir=${INSTALL_DIR} --disable-memcached-sasl && \
make && \
make install && \
cd -

RUN cp /opt/bref/lib/php/extensions/no-debug-zts-*/memcached.so /tmp/memcached.so

# Build the final image from the lambci image that is close to the production environment
FROM lambci/lambda:provided

# Copy things we installed to the final image
COPY --from=ext /opt/bref/include/libmemcached/ /opt/bref/include/libmemcached/
COPY --from=ext /opt/bref/include/libmemcached-1.0/ /opt/bref/include/libmemcached-1.0/
COPY --from=ext /opt/bref/include/libmemcachedutil-1.0/ /opt/bref/include/libmemcachedutil-1.0/
COPY --from=ext /opt/bref/include/libhashkit/ /opt/bref/include/libhashkit/
COPY --from=ext /opt/bref/include/libhashkit-1.0/ /opt/bref/include/libhashkit-1.0/

COPY --from=ext /opt/bref/lib/libhashkit.* /opt/bref/lib/
COPY --from=ext /opt/bref/lib/libmemcached.* /opt/bref/lib/
COPY --from=ext /opt/bref/lib/libmemcachedutil.* /opt/bref/lib/
COPY --from=ext /opt/bref/lib/pkgconfig/libmemcached.pc /opt/bref/lib/pkgconfig/libmemcached.pc

COPY --from=ext /tmp/memcache.so /opt/bref-extra/memcache.so
COPY --from=ext /tmp/memcached.so /opt/bref-extra/memcached.so
21 changes: 21 additions & 0 deletions layers/memcached/libmemcached-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff -up ./clients/memflush.cc.old ./clients/memflush.cc
--- ./clients/memflush.cc.old 2017-02-12 10:12:59.615209225 +0100
+++ ./clients/memflush.cc 2017-02-12 10:13:39.998382783 +0100
@@ -39,7 +39,7 @@ int main(int argc, char *argv[])
{
options_parse(argc, argv);

- if (opt_servers == false)
+ if (!opt_servers)
{
char *temp;

@@ -48,7 +48,7 @@ int main(int argc, char *argv[])
opt_servers= strdup(temp);
}

- if (opt_servers == false)
+ if (!opt_servers)
{
std::cerr << "No Servers provided" << std::endl;
exit(EXIT_FAILURE);

0 comments on commit c8b6b84

Please sign in to comment.