Dockerfile 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. ARG PHP_VERSION=8.3
  2. ARG ALPINE_VERSION=3.18
  3. FROM alpine:3.18.4 as sphinx-lint
  4. RUN apk add python3 py3-pip git \
  5. && pip install sphinx-lint
  6. # This must be the same as in CI's job, but `--null` must be changed to `-0` (Alpine)
  7. CMD git ls-files --cached -z -- '*.rst' \
  8. | xargs -0 -- python3 -m sphinxlint --enable all --disable trailing-whitespace --max-line-length 2000
  9. FROM php:${PHP_VERSION}-cli-alpine${ALPINE_VERSION} as base
  10. RUN curl --location --output /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions \
  11. && chmod +x /usr/local/bin/install-php-extensions \
  12. && install-php-extensions pcntl
  13. FROM base as base-dev
  14. # https://blog.codito.dev/2022/11/composer-binary-only-docker-images/
  15. # https://github.com/composer/docker/pull/250
  16. COPY --from=composer/composer:2-bin /composer /usr/local/bin/composer
  17. FROM base-dev as vendor
  18. COPY composer.json /fixer/composer.json
  19. WORKDIR /fixer
  20. RUN composer remove --dev infection/infection --no-update \
  21. && composer install --prefer-dist --no-dev --optimize-autoloader --no-scripts
  22. FROM base as dist
  23. RUN mkdir /code
  24. WORKDIR /code
  25. COPY src /fixer/src
  26. COPY php-cs-fixer /fixer/php-cs-fixer
  27. # Only take the dependencies (not composer itself) into the container
  28. COPY --from=vendor /fixer/vendor /fixer/vendor
  29. RUN ln -s /fixer/php-cs-fixer /usr/local/bin/php-cs-fixer
  30. ENTRYPOINT ["/usr/local/bin/php-cs-fixer"]
  31. FROM base-dev as dev
  32. ARG DOCKER_USER_ID
  33. ARG DOCKER_GROUP_ID
  34. ARG PHP_XDEBUG_VERSION
  35. RUN if [ ! -z "$DOCKER_GROUP_ID" ] && [ ! getent group "${DOCKER_GROUP_ID}" > /dev/null ]; \
  36. then addgroup -S -g "${DOCKER_GROUP_ID}" devs; \
  37. fi \
  38. && if [ ! -z "$DOCKER_USER_ID" ] && [ ! -z "$DOCKER_GROUP_ID" ] && [ ! getent passwd "${DOCKER_USER_ID}" > /dev/null ]; \
  39. then adduser -S -u "${DOCKER_USER_ID}" -G "$(getent group "${DOCKER_GROUP_ID}" | awk -F: '{printf $1}')" dev; \
  40. fi \
  41. && apk add git \
  42. && sync \
  43. && install-php-extensions pcov xdebug-${PHP_XDEBUG_VERSION} \
  44. && curl --location --output /usr/local/bin/xdebug https://github.com/julienfalque/xdebug/releases/download/v2.0.0/xdebug \
  45. && chmod +x /usr/local/bin/xdebug
  46. COPY docker/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini