Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide the commands to run Symfony Tests through Docker 🐳 #47102

Closed
29 changes: 29 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ARG DOCKER_PHP_VERSION=8.2

FROM php:${DOCKER_PHP_VERSION}-cli-bullseye

ENV DEBIAN_FRONTEND=noninteractive

# git is required to allow Composer to work with symfony/runtime
# ext-xsl is required by lorenzo/pinky through twig/inky-extra
# libonig-dev is required by the mbstring extension
# zip will allow Composer to install dependencies without using git clone,
# so that it won't hit the rate limits of Github
RUN apt-get update \
&& apt-get install --yes git libxslt-dev libzip-dev libonig-dev unzip \
&& apt-get clean ; rm -rf /var/lib/apt/lists/*

RUN pecl install apcu

# configure intl and xsl in 2 steps, otherwise it fails
RUN docker-php-ext-configure intl \
&& docker-php-ext-configure xsl \
&& docker-php-ext-install intl mbstring xsl zip \
&& docker-php-ext-enable apcu

# ensure that git is available
RUN git --version

COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
alexislefebvre marked this conversation as resolved.
Show resolved Hide resolved

WORKDIR /symfony
12 changes: 12 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@
"src/Symfony/Component/VarDumper/Resources/functions/dump.php"
]
},
"scripts": {
"docker-build": "docker build --build-arg DOCKER_PHP_VERSION=${DOCKER_PHP_VERSION} --tag symfony-tests .docker/",
"docker-run": "docker run --rm --tty --user $(id --user):$(id --group) --volume $(pwd):/symfony symfony-tests",
"docker-composer": "@docker-run env COMPOSER_ROOT_VERSION=6.3.x-dev composer update",
"docker-tests": "@docker-run ./phpunit"
},
"scripts-descriptions": {
"docker-build": "Build the Docker image, you can use a different version by defining “DOCKER_PHP_VERSION”, e.g. “env DOCKER_PHP_VERSION=\"8.1\" composer docker-build”",
"docker-run": "Base command to run Docker",
"docker-composer": "Install dependencies through Composer",
"docker-tests": "Run tests, you should pass arguments, e.g. “composer docker-tests src/Symfony/Component/DependencyInjection/” for testing a specific folder or “composer docker-tests src/Symfony/” to run the whole test suite in parallel. Options for PHPUnit must be prepend with --, e.g. “composer docker-tests -- --verbose --debug src/Symfony/Component/DependencyInjection/”"
},
"repositories": [
{
"type": "path",
Expand Down