Skip to content

Commit

Permalink
Merge pull request #262 from alquerci/add-docker-compose
Browse files Browse the repository at this point in the history
Add consistent local environment for testing with docker and docker-compose
  • Loading branch information
thePanz authored Nov 25, 2022
2 parents 6f521e9 + e8cbc9d commit 6b82513
Show file tree
Hide file tree
Showing 10 changed files with 571 additions and 1 deletion.
57 changes: 57 additions & 0 deletions .docker/php53/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM buildpack-deps:jessie

ENV PHP_VERSION 5.3.29

# php 5.3 needs older autoconf
RUN set -eux; \
\
apt-get update; \
apt-get install -y \
curl \
autoconf2.13 \
; \
rm -r /var/lib/apt/lists/*; \
\
curl -sSLfO http://launchpadlibrarian.net/140087283/libbison-dev_2.7.1.dfsg-1_amd64.deb; \
curl -sSLfO http://launchpadlibrarian.net/140087282/bison_2.7.1.dfsg-1_amd64.deb; \
dpkg -i libbison-dev_2.7.1.dfsg-1_amd64.deb; \
dpkg -i bison_2.7.1.dfsg-1_amd64.deb; \
rm *.deb; \
\
curl -sSLf "https://php.net/get/php-$PHP_VERSION.tar.bz2/from/this/mirror" -o php.tar.bz2; \
echo 'c4e1cf6972b2a9c7f2777a18497d83bf713cdbecabb65d3ff62ba441aebb0091 php.tar.bz2' | sha256sum -cw --status; \
\
mkdir -p /usr/src/php; \
tar -xf php.tar.bz2 -C /usr/src/php --strip-components=1; \
rm php.tar.bz2*; \
\
cd /usr/src/php; \
./buildconf --force; \
./configure --disable-cgi \
$(command -v apxs2 > /dev/null 2>&1 && echo '--with-apxs2' || true) \
--with-pdo-mysql \
--with-zlib \
--enable-mbstring \
; \
make -j"$(nproc)"; \
make install; \
\
dpkg -r \
bison \
libbison-dev \
; \
apt-get purge -y --auto-remove \
autoconf2.13 \
; \
rm -r /usr/src/php

# Install APC PHP extension
#
RUN set -eux; \
\
pecl install apc-3.1.13; \
echo 'extension=apc.so' >> /usr/local/lib/php.ini; \
\
rm -r /tmp/pear;

CMD ["php", "-a"]
34 changes: 34 additions & 0 deletions .docker/php54/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM php:5.4-cli

RUN docker-php-ext-install pdo
RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install mbstring

# Install APC PHP extension
#
RUN set -eux; \
pecl install apc-3.1.13; \
docker-php-ext-enable apc; \
rm -r /tmp/pear;

# Install memcache PHP extension
#
ARG MEMCACHE_VERSION
RUN set -eux; \
buildDeps=' \
libzip-dev \
'; \
apt-get update; \
apt-get install -y --no-upgrade --no-install-recommends \
$buildDeps \
; \
\
pecl install memcache-${MEMCACHE_VERSION}; \
docker-php-ext-enable memcache; \
\
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \
$buildDeps \
; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*; \
rm -r /tmp/pear
40 changes: 40 additions & 0 deletions .docker/php55_71/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
ARG PHP_TAG
FROM php:${PHP_TAG}

RUN docker-php-ext-install pdo
RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install mbstring

# Install APCu PHP extension
#
ARG APCU_VERSION
RUN set -eux; \
\
test x"" = x"${APCU_VERSION}" || { \
pecl install apcu-${APCU_VERSION}; \
docker-php-ext-enable apcu; \
\
rm -r /tmp/pear; \
}

# Install memcache PHP extension
#
ARG MEMCACHE_VERSION
RUN set -eux; \
buildDeps=' \
libzip-dev \
'; \
apt-get update; \
apt-get install -y --no-upgrade --no-install-recommends \
$buildDeps \
; \
\
pecl install memcache-${MEMCACHE_VERSION}; \
docker-php-ext-enable memcache; \
\
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \
$buildDeps \
; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*; \
rm -r /tmp/pear
56 changes: 56 additions & 0 deletions .docker/php72_73/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
ARG PHP_VERSION
FROM php:${PHP_VERSION}-cli

RUN docker-php-ext-install pdo
RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install mbstring

# Install APCu PHP extension
#
ARG APCU_VERSION
RUN set -eux; \
\
test x"" = x"${APCU_VERSION}" || { \
pecl install apcu-${APCU_VERSION}; \
docker-php-ext-enable apcu; \
\
rm -r /tmp/pear; \
}

# Install memcache PHP extension
#
ARG MEMCACHE_VERSION
RUN set -eux; \
buildDeps=' \
libzip-dev \
'; \
apt-get update; \
apt-get install -y --no-upgrade --no-install-recommends \
$buildDeps \
; \
\
pecl install memcache-${MEMCACHE_VERSION}; \
docker-php-ext-enable memcache; \
\
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \
$buildDeps \
; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*; \
rm -r /tmp/pear

# For consistent mime type file guesser
RUN set -eux; \
distFilePath=`which file`; \
\
mv ${distFilePath} ${distFilePath}.dist; \
{ \
echo '#! /bin/sh -eu'; \
echo ''; \
echo "${distFilePath}"'.dist "$@" | sed -e s,application/x-pie-executable,application/x-executable,g'; \
} | tee ${distFilePath}; \
\
chmod +x ${distFilePath}; \
\
file /bin/ls --mime | grep application/x-executable; \
:;
68 changes: 68 additions & 0 deletions .docker/php74_81/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
ARG PHP_VERSION
FROM php:${PHP_VERSION}-cli

RUN docker-php-ext-install pdo
RUN docker-php-ext-install pdo_mysql

# Install mbstring PHP extension
#
RUN set -eux; \
apt-get update; \
apt-get install -y --no-upgrade --no-install-recommends \
libonig-dev \
; \
\
apt-get clean; \
rm -rf /var/lib/apt/lists/*; \
\
docker-php-ext-install mbstring

# Install APCu PHP extension
#
ARG APCU_VERSION
RUN set -eux; \
\
test x"" = x"${APCU_VERSION}" || { \
pecl install apcu-${APCU_VERSION}; \
docker-php-ext-enable apcu; \
\
rm -r /tmp/pear; \
}

# Install memcache PHP extension
#
ARG MEMCACHE_VERSION
RUN set -eux; \
buildDeps=' \
libzip-dev \
'; \
apt-get update; \
apt-get install -y --no-upgrade --no-install-recommends \
$buildDeps \
; \
\
pecl install memcache-${MEMCACHE_VERSION}; \
docker-php-ext-enable memcache; \
\
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \
$buildDeps \
; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*; \
rm -r /tmp/pear

# For consistent mime type file guesser
RUN set -eux; \
distFilePath=`which file`; \
\
mv ${distFilePath} ${distFilePath}.dist; \
{ \
echo '#! /bin/sh -eu'; \
echo ''; \
echo "${distFilePath}"'.dist "$@" | sed -e s,application/x-pie-executable,application/x-executable,g'; \
} | tee ${distFilePath}; \
\
chmod +x ${distFilePath}; \
\
file /bin/ls --mime | grep application/x-executable; \
:;
11 changes: 11 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Environment variables used by docker-compose for test.
#
# Copy to `.env` in order to use it.
#

# APC test are disabled.
#
# To enable them in order to provide a fix, set to "on".
#
APC_ENABLE_CLI=off
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,37 @@ Option 2: Using Git submodules:
git submodule add https://github.com/FriendsOfSymfony1/symfony1.git lib/vendor/symfony
git submodule update --init --recursive


Tests
-----

### Prerequisites

* docker-engine version 17.12.0+
* docker-compose version 1.20.0+

### How to execute all tests on all supported PHP versions and dependencies?

test/bin/test

### For PHP 7.3 and for lowest dependencies versions?

test/bin/test php73 lowest

### For PHP 7.3 and for highest dependencies versions?

test/bin/test php73 highest

### For executing a dedicated test file?

test/bin/test php73 highest test/unit/cache/sfAPCCacheTest.php


### When you finish your work day, do not forget to clean up your desk

docker-compose down


Documentation
-------------

Expand Down
Loading

0 comments on commit 6b82513

Please sign in to comment.