Skip to content

Commit cf59be0

Browse files
alquercithePanz
andauthored
Add consistent local environment for testing with docker and docker-compose (FriendsOfSymfony1#86)
Related to FriendsOfSymfony1/symfony1#261 Co-authored-by: Emanuele Panzeri <[email protected]>
1 parent ae10c17 commit cf59be0

File tree

9 files changed

+385
-0
lines changed

9 files changed

+385
-0
lines changed

.docker/php53/Dockerfile

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
CMD ["php", "-a"]

.docker/php54/Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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

.docker/php55_71/Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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

.docker/php72_73/Dockerfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
# For consistent mime type file guesser
9+
RUN set -eux; \
10+
distFilePath=`which file`; \
11+
\
12+
mv ${distFilePath} ${distFilePath}.dist; \
13+
{ \
14+
echo '#! /bin/sh -eu'; \
15+
echo ''; \
16+
echo "${distFilePath}"'.dist "$@" | sed -e s,application/x-pie-executable,application/x-executable,g'; \
17+
} | tee ${distFilePath}; \
18+
\
19+
chmod +x ${distFilePath}; \
20+
\
21+
file /bin/ls --mime | grep application/x-executable; \
22+
:;

.docker/php74_81/Dockerfile

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
# For consistent mime type file guesser
21+
RUN set -eux; \
22+
distFilePath=`which file`; \
23+
\
24+
mv ${distFilePath} ${distFilePath}.dist; \
25+
{ \
26+
echo '#! /bin/sh -eu'; \
27+
echo ''; \
28+
echo "${distFilePath}"'.dist "$@" | sed -e s,application/x-pie-executable,application/x-executable,g'; \
29+
} | tee ${distFilePath}; \
30+
\
31+
chmod +x ${distFilePath}; \
32+
\
33+
file /bin/ls --mime | grep application/x-executable; \
34+
:;

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
tests/DoctrineTest/doctrine_tests/*
22
*TestCase.php
3+
/composer.lock
34
/tests/tmp
45
/tests/foo.sq3
6+
/vendor/

README.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Doctrine1
2+
=========
3+
4+
About this version
5+
------------------
6+
7+
This is a community driven fork of doctrine 1, as official support has been interrupted long time ago.
8+
9+
**Do not use it for new projects: this version is great to improve existing symfony1 applications using doctrine1, but [Doctrine2](https://www.doctrine-project.org/projects/orm.html) is the way to go today.**
10+
11+
12+
Requirements
13+
------------
14+
15+
PHP 5.3 and up.
16+
17+
18+
Installation
19+
------------
20+
21+
Using [Composer](http://getcomposer.org/doc/00-intro.md) as dependency management:
22+
23+
composer require friendsofsymfony1/doctrine1 "1.5.*"
24+
composer install
25+
26+
27+
28+
Tests
29+
-----
30+
31+
### Prerequisites
32+
33+
* docker-engine version 17.12.0+
34+
* docker-compose version 1.20.0+
35+
36+
### How to execute all tests on all supported PHP versions and dependencies?
37+
38+
tests/bin/test
39+
40+
### When you finish your work day, do not forget to clean up your desk
41+
42+
docker-compose down
43+
44+
45+
Documentation
46+
-------------
47+
48+
Read the official [doctrine1 documentation](https://web.archive.org/web/20171008235327/http://docs.doctrine-project.org:80/projects/doctrine1/en/latest/en/manual/index.html)
49+
50+
51+
Contributing
52+
------------
53+
54+
You can send pull requests or create an issue.

docker-compose.yml

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
version: '3.5'
2+
3+
volumes:
4+
db_socket:
5+
6+
services:
7+
composer:
8+
image: composer
9+
working_dir: /app
10+
volumes:
11+
- .:/app
12+
entrypoint:
13+
- sh
14+
- -c
15+
- |
16+
exec tail -f /dev/null
17+
18+
php53:
19+
build: .docker/php53
20+
working_dir: /app/tests
21+
volumes:
22+
- .:/app
23+
- db_socket:/var/run/mysqld
24+
entrypoint:
25+
- sh
26+
- -c
27+
- |
28+
{
29+
echo 'pdo_mysql.default_socket = /var/run/mysqld/mysql.sock'
30+
echo 'memory_limit = -1'
31+
echo 'short_open_tag = off'
32+
echo 'magic_quotes_gpc = off'
33+
echo 'date.timezone = "UTC"'
34+
} | tee -a /usr/local/lib/php.ini
35+
36+
exec tail -f /dev/null
37+
38+
php54: &services_php54
39+
build:
40+
context: .docker/php54
41+
working_dir: /app/tests
42+
volumes:
43+
- .:/app
44+
- db_socket:/var/run/mysqld
45+
entrypoint:
46+
- sh
47+
- -c
48+
- |
49+
{
50+
echo 'pdo_mysql.default_socket = /var/run/mysqld/mysql.sock'
51+
echo 'memory_limit = -1'
52+
echo 'short_open_tag = off'
53+
echo 'magic_quotes_gpc = off'
54+
echo 'date.timezone = "UTC"'
55+
} | tee -a /usr/local/etc/php/php.ini
56+
57+
exec tail -f /dev/null
58+
depends_on:
59+
- db
60+
61+
php55:
62+
<<: *services_php54
63+
build:
64+
context: .docker/php55_71
65+
args:
66+
PHP_TAG: '5.5-cli'
67+
68+
php56:
69+
<<: *services_php54
70+
build:
71+
context: .docker/php55_71
72+
args:
73+
PHP_TAG: '5.6-cli-jessie'
74+
75+
php70:
76+
<<: *services_php54
77+
build:
78+
context: .docker/php55_71
79+
args:
80+
PHP_TAG: '7.0-cli-jessie'
81+
82+
php71:
83+
<<: *services_php54
84+
build:
85+
context: .docker/php55_71
86+
args:
87+
PHP_TAG: '7.1-cli-jessie'
88+
89+
php72:
90+
<<: *services_php54
91+
build:
92+
context: .docker/php72_73
93+
args:
94+
PHP_VERSION: '7.2'
95+
96+
php73:
97+
<<: *services_php54
98+
build:
99+
context: .docker/php72_73
100+
args:
101+
PHP_VERSION: '7.3'
102+
103+
php74:
104+
<<: *services_php54
105+
build:
106+
context: .docker/php74_81
107+
args:
108+
PHP_VERSION: '7.4'
109+
110+
php80:
111+
<<: *services_php54
112+
build:
113+
context: .docker/php74_81
114+
args:
115+
PHP_VERSION: '8.0'
116+
117+
php81:
118+
<<: *services_php54
119+
build:
120+
context: .docker/php74_81
121+
args:
122+
PHP_VERSION: '8.1'
123+
124+
db:
125+
image: mysql:5.5.62
126+
environment:
127+
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
128+
volumes:
129+
- db_socket:/tmp
130+
entrypoint:
131+
- bash
132+
- -c
133+
- |
134+
{
135+
echo "CREATE DATABASE IF NOT EXISTS test;"
136+
} | tee /docker-entrypoint-initdb.d/init.sql
137+
138+
exec /usr/local/bin/docker-entrypoint.sh mysqld

tests/bin/test

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#! /bin/sh -eu
2+
#
3+
# [<php-version>] [<dependency-preference>] [<php-test-runtime>]
4+
#
5+
# <php-version> example: php70
6+
# <dependency-preference> One of highest (default), lowest
7+
#
8+
# Both arguments can be a space separated value.
9+
# Example: "lowest highest"
10+
#
11+
12+
# Configuration
13+
#
14+
dependencyPreferences='highest'
15+
skipPHPVersions='php8'
16+
17+
# Commands
18+
#
19+
dcexec="docker-compose exec -u `id -u`:`id -g`"
20+
composerUpdate='composer update --prefer-dist --no-suggest --optimize-autoloader'
21+
doctrineTestSuite='run.php'
22+
23+
# Parse arguments
24+
#
25+
phpVersions="${1-}"
26+
dependencyPreferences="${2-${dependencyPreferences}}"
27+
phpTestRuntime="${3-${doctrineTestSuite}}"
28+
29+
script ()
30+
{
31+
echo
32+
echo
33+
echo $0 ${1} ${2}
34+
echo
35+
${dcexec} ${1} php ${phpTestRuntime}
36+
}
37+
38+
scriptAll ()
39+
{
40+
for dependencyPreference in ${dependencyPreferences}
41+
do
42+
install_${dependencyPreference}
43+
44+
for phpVersion in ${phpVersions}
45+
do
46+
script ${phpVersion} ${dependencyPreference}
47+
done
48+
done
49+
}
50+
51+
fetchAllPHPVersions ()
52+
{
53+
docker-compose 2>/dev/null ps --services --filter status=running \
54+
| grep php \
55+
| sort \
56+
| grep -v ${skipPHPVersions}
57+
}
58+
59+
install_highest ()
60+
{
61+
${dcexec} composer ${composerUpdate}
62+
}
63+
64+
install_lowest ()
65+
{
66+
${dcexec} composer ${composerUpdate} --prefer-lowest
67+
}
68+
69+
echo '+ docker-compose build'
70+
docker-compose up -d --build --remove-orphans > /dev/null
71+
72+
test x"" != x"${phpVersions}" || {
73+
phpVersions=`fetchAllPHPVersions`
74+
}
75+
76+
scriptAll

0 commit comments

Comments
 (0)