features icon indicating copy to clipboard operation
features copied to clipboard

The PHP feature has a very bad performance (in GitHub Codespaces)

Open rugk opened this issue 3 years ago • 2 comments

I can use this e.g. as the image: mcr.microsoft.com/devcontainers/php

In GitHub Codespaces that results in that: grafik

It is slow, very slow, because – I guess – it literally compiles PHP – given it depends on the official PHP docker container and they famously compile Docker from scratch there.

I just wonder why nothing is cached? Afterall, it should not build for minutes and these basic images should be cached. For "quick development", which GitHub Codespaces is aimed at, that is a no-go.

This is my full .devcontainer file:

{
    "name": "PHP",
    "image": "mcr.microsoft.com/devcontainers/php",
    "customizations": {
        "vscode": {
            "extensions": [
				"github.codespaces",
				"DEVSENSE.phptools-vscode",
				"EditorConfig.EditorConfig",
				"dbaeumer.vscode-eslint",
				"raymondcamden.CSSLint",
				"DEVSENSE.composer-php-vscode"
			]
        },
        "codespaces": {
            "repositories": {
                "PrivateBin/*": {
                    "permissions": {
                        "pull_requests": "write"
                    }
                }
            }
        }
    },
    "forwardPorts": [
        8080
    ],
    "features": {
        "ghcr.io/devcontainers/features/php:1": {
            "installComposer": true,
            "version": "latest"
        }
    },
    "postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html",
    "postStartCommand": "apache2ctl start"
}

rugk avatar Aug 24 '23 19:08 rugk

OH I am sorry it was actually the ghcr.io/devcontainers/features/php thing that caused this, but well... still bad. Could you possibly move this issue to the correct repo? Thanks!

rugk avatar Aug 24 '23 19:08 rugk

Hi 👋

Thanks for raising the issue!

OH I am sorry it was actually the ghcr.io/devcontainers/features/php thing that caused this, but well... still bad. Could you possibly move this issue to the correct repo? Thanks!

Yes, pulling the mcr.microsoft.com/devcontainers/php image is faster than using the php Feature. The php Feature is building php from source, which is the cause of why the Feature takes longer than the image.

We should definitely try to improve the performance of php Feature, few ideas -

  • Add a new Feature option to install php from apt, which will definitely be faster
  • Find official and supported prebuilt artifacts/binaries which we could use instead of building php from source, something similar to https://github.com/devcontainers/features/issues/75

In the meanwhile, @rugk have you looked at setting up prebuilds? That will make your codespace creations faster. See https://docs.github.com/en/codespaces/prebuilding-your-codespaces/about-github-codespaces-prebuilds

samruddhikhandale avatar Aug 25 '23 00:08 samruddhikhandale