Skip to content

Commit 6b82513

Browse files
authored
Merge pull request #262 from alquerci/add-docker-compose
Add consistent local environment for testing with docker and docker-compose
2 parents 6f521e9 + e8cbc9d commit 6b82513

File tree

10 files changed

+571
-1
lines changed

10 files changed

+571
-1
lines changed

.docker/php53/Dockerfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
FROM buildpack-deps:jessie
2+
3+
ENV PHP_VERSION 5.3.29
4+
5+
# php 5.3 needs older autoconf
6+
RUN set -eux; \
7+
\
8+
apt-get update; \
9+
apt-get install -y \
10+
curl \
11+
autoconf2.13 \
12+
; \
13+
rm -r /var/lib/apt/lists/*; \
14+
\
15+
curl -sSLfO http://launchpadlibrarian.net/140087283/libbison-dev_2.7.1.dfsg-1_amd64.deb; \
16+
curl -sSLfO http://launchpadlibrarian.net/140087282/bison_2.7.1.dfsg-1_amd64.deb; \
17+
dpkg -i libbison-dev_2.7.1.dfsg-1_amd64.deb; \
18+
dpkg -i bison_2.7.1.dfsg-1_amd64.deb; \
19+
rm *.deb; \
20+
\
21+
curl -sSLf "https://php.net/get/php-$PHP_VERSION.tar.bz2/from/this/mirror" -o php.tar.bz2; \
22+
echo 'c4e1cf6972b2a9c7f2777a18497d83bf713cdbecabb65d3ff62ba441aebb0091 php.tar.bz2' | sha256sum -cw --status; \
23+
\
24+
mkdir -p /usr/src/php; \
25+
tar -xf php.tar.bz2 -C /usr/src/php --strip-components=1; \
26+
rm php.tar.bz2*; \
27+
\
28+
cd /usr/src/php; \
29+
./buildconf --force; \
30+
./configure --disable-cgi \
31+
$(command -v apxs2 > /dev/null 2>&1 && echo '--with-apxs2' || true) \
32+
--with-pdo-mysql \
33+
--with-zlib \
34+
--enable-mbstring \
35+
; \
36+
make -j"$(nproc)"; \
37+
make install; \
38+
\
39+
dpkg -r \
40+
bison \
41+
libbison-dev \
42+
; \
43+
apt-get purge -y --auto-remove \
44+
autoconf2.13 \
45+
; \
46+
rm -r /usr/src/php
47+
48+
# Install APC PHP extension
49+
#
50+
RUN set -eux; \
51+
\
52+
pecl install apc-3.1.13; \
53+
echo 'extension=apc.so' >> /usr/local/lib/php.ini; \
54+
\
55+
rm -r /tmp/pear;
56+
57+
CMD ["php", "-a"]

.docker/php54/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM php:5.4-cli
2+
3+
RUN docker-php-ext-install pdo
4+
RUN docker-php-ext-install pdo_mysql
5+
RUN docker-php-ext-install mbstring
6+
7+
# Install APC PHP extension
8+
#
9+
RUN set -eux; \
10+
pecl install apc-3.1.13; \
11+
docker-php-ext-enable apc; \
12+
rm -r /tmp/pear;
13+
14+
# Install memcache PHP extension
15+
#
16+
ARG MEMCACHE_VERSION
17+
RUN set -eux; \
18+
buildDeps=' \
19+
libzip-dev \
20+
'; \
21+
apt-get update; \
22+
apt-get install -y --no-upgrade --no-install-recommends \
23+
$buildDeps \
24+
; \
25+
\
26+
pecl install memcache-${MEMCACHE_VERSION}; \
27+
docker-php-ext-enable memcache; \
28+
\
29+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \
30+
$buildDeps \
31+
; \
32+
apt-get clean; \
33+
rm -rf /var/lib/apt/lists/*; \
34+
rm -r /tmp/pear

.docker/php55_71/Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
ARG PHP_TAG
2+
FROM php:${PHP_TAG}
3+
4+
RUN docker-php-ext-install pdo
5+
RUN docker-php-ext-install pdo_mysql
6+
RUN docker-php-ext-install mbstring
7+
8+
# Install APCu PHP extension
9+
#
10+
ARG APCU_VERSION
11+
RUN set -eux; \
12+
\
13+
test x"" = x"${APCU_VERSION}" || { \
14+
pecl install apcu-${APCU_VERSION}; \
15+
docker-php-ext-enable apcu; \
16+
\
17+
rm -r /tmp/pear; \
18+
}
19+
20+
# Install memcache PHP extension
21+
#
22+
ARG MEMCACHE_VERSION
23+
RUN set -eux; \
24+
buildDeps=' \
25+
libzip-dev \
26+
'; \
27+
apt-get update; \
28+
apt-get install -y --no-upgrade --no-install-recommends \
29+
$buildDeps \
30+
; \
31+
\
32+
pecl install memcache-${MEMCACHE_VERSION}; \
33+
docker-php-ext-enable memcache; \
34+
\
35+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \
36+
$buildDeps \
37+
; \
38+
apt-get clean; \
39+
rm -rf /var/lib/apt/lists/*; \
40+
rm -r /tmp/pear

.docker/php72_73/Dockerfile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
ARG PHP_VERSION
2+
FROM php:${PHP_VERSION}-cli
3+
4+
RUN docker-php-ext-install pdo
5+
RUN docker-php-ext-install pdo_mysql
6+
RUN docker-php-ext-install mbstring
7+
8+
# Install APCu PHP extension
9+
#
10+
ARG APCU_VERSION
11+
RUN set -eux; \
12+
\
13+
test x"" = x"${APCU_VERSION}" || { \
14+
pecl install apcu-${APCU_VERSION}; \
15+
docker-php-ext-enable apcu; \
16+
\
17+
rm -r /tmp/pear; \
18+
}
19+
20+
# Install memcache PHP extension
21+
#
22+
ARG MEMCACHE_VERSION
23+
RUN set -eux; \
24+
buildDeps=' \
25+
libzip-dev \
26+
'; \
27+
apt-get update; \
28+
apt-get install -y --no-upgrade --no-install-recommends \
29+
$buildDeps \
30+
; \
31+
\
32+
pecl install memcache-${MEMCACHE_VERSION}; \
33+
docker-php-ext-enable memcache; \
34+
\
35+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \
36+
$buildDeps \
37+
; \
38+
apt-get clean; \
39+
rm -rf /var/lib/apt/lists/*; \
40+
rm -r /tmp/pear
41+
42+
# For consistent mime type file guesser
43+
RUN set -eux; \
44+
distFilePath=`which file`; \
45+
\
46+
mv ${distFilePath} ${distFilePath}.dist; \
47+
{ \
48+
echo '#! /bin/sh -eu'; \
49+
echo ''; \
50+
echo "${distFilePath}"'.dist "$@" | sed -e s,application/x-pie-executable,application/x-executable,g'; \
51+
} | tee ${distFilePath}; \
52+
\
53+
chmod +x ${distFilePath}; \
54+
\
55+
file /bin/ls --mime | grep application/x-executable; \
56+
:;

.docker/php74_81/Dockerfile

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
ARG PHP_VERSION
2+
FROM php:${PHP_VERSION}-cli
3+
4+
RUN docker-php-ext-install pdo
5+
RUN docker-php-ext-install pdo_mysql
6+
7+
# Install mbstring PHP extension
8+
#
9+
RUN set -eux; \
10+
apt-get update; \
11+
apt-get install -y --no-upgrade --no-install-recommends \
12+
libonig-dev \
13+
; \
14+
\
15+
apt-get clean; \
16+
rm -rf /var/lib/apt/lists/*; \
17+
\
18+
docker-php-ext-install mbstring
19+
20+
# Install APCu PHP extension
21+
#
22+
ARG APCU_VERSION
23+
RUN set -eux; \
24+
\
25+
test x"" = x"${APCU_VERSION}" || { \
26+
pecl install apcu-${APCU_VERSION}; \
27+
docker-php-ext-enable apcu; \
28+
\
29+
rm -r /tmp/pear; \
30+
}
31+
32+
# Install memcache PHP extension
33+
#
34+
ARG MEMCACHE_VERSION
35+
RUN set -eux; \
36+
buildDeps=' \
37+
libzip-dev \
38+
'; \
39+
apt-get update; \
40+
apt-get install -y --no-upgrade --no-install-recommends \
41+
$buildDeps \
42+
; \
43+
\
44+
pecl install memcache-${MEMCACHE_VERSION}; \
45+
docker-php-ext-enable memcache; \
46+
\
47+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=true \
48+
$buildDeps \
49+
; \
50+
apt-get clean; \
51+
rm -rf /var/lib/apt/lists/*; \
52+
rm -r /tmp/pear
53+
54+
# For consistent mime type file guesser
55+
RUN set -eux; \
56+
distFilePath=`which file`; \
57+
\
58+
mv ${distFilePath} ${distFilePath}.dist; \
59+
{ \
60+
echo '#! /bin/sh -eu'; \
61+
echo ''; \
62+
echo "${distFilePath}"'.dist "$@" | sed -e s,application/x-pie-executable,application/x-executable,g'; \
63+
} | tee ${distFilePath}; \
64+
\
65+
chmod +x ${distFilePath}; \
66+
\
67+
file /bin/ls --mime | grep application/x-executable; \
68+
:;

.env.dist

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#
2+
# Environment variables used by docker-compose for test.
3+
#
4+
# Copy to `.env` in order to use it.
5+
#
6+
7+
# APC test are disabled.
8+
#
9+
# To enable them in order to provide a fix, set to "on".
10+
#
11+
APC_ENABLE_CLI=off

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,37 @@ Option 2: Using Git submodules:
5454
git submodule add https://github.com/FriendsOfSymfony1/symfony1.git lib/vendor/symfony
5555
git submodule update --init --recursive
5656

57+
58+
Tests
59+
-----
60+
61+
### Prerequisites
62+
63+
* docker-engine version 17.12.0+
64+
* docker-compose version 1.20.0+
65+
66+
### How to execute all tests on all supported PHP versions and dependencies?
67+
68+
test/bin/test
69+
70+
### For PHP 7.3 and for lowest dependencies versions?
71+
72+
test/bin/test php73 lowest
73+
74+
### For PHP 7.3 and for highest dependencies versions?
75+
76+
test/bin/test php73 highest
77+
78+
### For executing a dedicated test file?
79+
80+
test/bin/test php73 highest test/unit/cache/sfAPCCacheTest.php
81+
82+
83+
### When you finish your work day, do not forget to clean up your desk
84+
85+
docker-compose down
86+
87+
5788
Documentation
5889
-------------
5990

0 commit comments

Comments
 (0)