Sign inSign up

wormaster/symfony-php-ci

By wormaster

•Updated 7 months ago

Alpine + php8.3 + xdebug + common libs. Image for testing symfony projects in CI environments

Image
Languages & frameworks
Integration & delivery
Developer tools
0

162

wormaster/symfony-php-ci repository overview

⁠Symfony PHP CI for GitLab Runner

Lightweight Docker image for GitLab CI jobs in Symfony/PHP projects.

Built for common backend CI tasks:

  • run phpunit
  • collect test coverage
  • install Composer dependencies
  • access private repositories over SSH

⁠Included

Base image:

  • php:8.3-cli-alpine

Preinstalled tools:

  • Composer
  • Git
  • OpenSSH client
  • Bash
  • curl
  • unzip / zip

PHP extensions:

  • intl
  • zip
  • gd
  • pdo_sqlite
  • xdebug

⁠Usage in GitLab CI

backend:phpunit:
  stage: backend
  image: wormaster/symfony-php-ci:8.3
  coverage: '/^\s*Lines:\s*([0-9]+\.[0-9]+)\%/'
  before_script:
    - eval "$(ssh-agent -s)"
    - chmod 400 "$SSH_PRIVATE_KEY"
    - ssh-add "$SSH_PRIVATE_KEY"
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - cp "$SSH_KNOWN_HOSTS" ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
    - cd backend
    - composer install --prefer-dist --no-interaction --no-progress
  script:
    - php -d xdebug.mode=coverage bin/phpunit --coverage-text --colors=never --log-junit var/phpunit.junit.xml
  artifacts:
    when: always
    reports:
      junit: backend/var/phpunit.junit.xml
    paths:
      - backend/var/phpunit.junit.xml
    expire_in: 1 week

⁠Required GitLab CI/CD variables

⁠SSH_PRIVATE_KEY

Private SSH key used by the pipeline to access private git repositories or private Composer dependencies.

Recommended settings:

  • Type: File
  • Key: SSH_PRIVATE_KEY

Used in CI as:

chmod 400 "$SSH_PRIVATE_KEY"
ssh-add "$SSH_PRIVATE_KEY"
⁠SSH_KNOWN_HOSTS

known_hosts file with SSH host fingerprints for the servers used in the pipeline.

Recommended settings:

  • Type: File
  • Key: SSH_KNOWN_HOSTS

Used in CI as:

mkdir -p ~/.ssh
chmod 700 ~/.ssh
cp "$SSH_KNOWN_HOSTS" ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts

⁠Generate known_hosts

Example:

ssh-keyscan git.example.com > known_hosts

For a custom SSH port:

ssh-keyscan -p 2222 git.example.com > known_hosts

Store the generated file as the SSH_KNOWN_HOSTS GitLab variable with type File.

⁠Notes

  • SSH_PRIVATE_KEY and SSH_KNOWN_HOSTS should be stored as File variables.
  • The image provides only the CI runtime environment.
  • Project dependencies are still installed in the pipeline with composer install.
  • xdebug is included for coverage collection.

Tag summary

Content type

Image

Digest

sha256:27be5502b…

Size

161.5 MB

Last updated

7 months ago

docker pull wormaster/symfony-php-ci:8.3