Dockerfile 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. ARG PHP_VERSION
  2. ARG ALPINE_VERSION=3.18
  3. FROM php:${PHP_VERSION}-cli-alpine${ALPINE_VERSION}
  4. ARG DOCKER_USER_ID
  5. ARG DOCKER_GROUP_ID
  6. ARG PHP_XDEBUG_VERSION
  7. # https://blog.codito.dev/2022/11/composer-binary-only-docker-images/
  8. # https://github.com/composer/docker/pull/250
  9. COPY --from=composer/composer:2-bin /composer /usr/local/bin/composer
  10. RUN if ! getent group "${DOCKER_GROUP_ID}" > /dev/null; \
  11. then addgroup -S -g "${DOCKER_GROUP_ID}" devs; \
  12. fi \
  13. && if ! getent passwd "${DOCKER_USER_ID}" > /dev/null; \
  14. then adduser -S -u "${DOCKER_USER_ID}" -G "$(getent group "${DOCKER_GROUP_ID}" | awk -F: '{printf $1}')" dev; \
  15. fi \
  16. # php extensions
  17. && curl --location --output /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions \
  18. && chmod +x /usr/local/bin/install-php-extensions \
  19. && sync \
  20. && install-php-extensions \
  21. pcntl \
  22. xdebug-${PHP_XDEBUG_VERSION} \
  23. # xdebug command
  24. && curl --location --output /usr/local/bin/xdebug https://github.com/julienfalque/xdebug/releases/download/v2.0.0/xdebug \
  25. && chmod +x /usr/local/bin/xdebug
  26. COPY docker/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini