Coder Social home page Coder Social logo

syntaxc4-msft / composerextension Goto Github PK

View Code? Open in Web Editor NEW
15.0 15.0 7.0 135 KB

Brings Composer Support to Azure Websites via a Site Extension

Home Page: http://www.siteextensions.net

License: MIT License

HTML 63.03% Batchfile 36.97%
azure composer php

composerextension's People

Contributors

bretstateham avatar finvamp1 avatar hajekj avatar marchie avatar satoryu avatar syntaxc4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

composerextension's Issues

Add Composer 2 support?

Is is possible to add support for Composer 2?

I noticed Azure is running v1.8.5. I found this out by going to Azure Portal → App Service → advanced tools → debug console → CMD:

	D:\home>composer --version
	Composer version 1.8.5 2019-04-09 17:46:47

Thanks!

composer install frequently fails when using Git deployment

When using Local Git method for deployment, composer install frequently fails to install updates on deployment

remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id '9822aac992'.
remote: Running custom deployment command...
remote: Running deployment command...
remote: Install Dependencies with Composer
remote: Installing dependencies from lock file
remote: Verifying lock file contents can be installed on current platform.
remote: Package operations: 0 installs, 2 updates, 0 removals
remote:   - Downloading symfony/translation (v5.2.2)
remote:   - Downloading nesbot/carbon (2.44.0)
remote:   - Upgrading symfony/translation (v5.2.1 => v5.2.2): Extracting archive
remote:     Update of symfony/translation failed
remote: ......
remote:   - Upgrading nesbot/carbon (2.43.0 => 2.44.0): Extracting archive
remote:     Update of nesbot/carbon failed
remote:
remote:
remote:   [RuntimeException]
remote:   Could not delete D:\home\site\repository/vendor/composer/tmp-76b8eabe55017bfdfc0c60d8931c3967:
remote:   This can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed
remote:
remote:
remote: An error has occurred during web site deployment.

Composer failure should halt execution of deploy.cmd

I have encountered an issue today where Composer failed part way through retrieving dependencies. However, the partially downloaded dependencies were then copied across to the live site, which resulted in an outage.

Currently, the deploy.cmd file does not check for an error before calling the Kudu sync command:

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Download Dependencies with Composer
:: -----------------

echo Install Dependencies with Composer

call composer install %COMPOSER_ARGS%

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

echo Handling Basic Web Site deployment.

:: 1. KuduSync
call %KUDU_SYNC_CMD% -v 50 -f "%DEPLOYMENT_SOURCE%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
IF !ERRORLEVEL! NEQ 0 goto error

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Adding IF !ERRORLEVEL! NEQ 0 goto error after the call composer install %COMPOSER_ARGS% line will prevent this from happening.

Load custom PHP extensions when running composer

Azure does not auto-load PHP binary extensions (such as LDAP). The user must upload their own copy of the binary (compatible for the configured version of PHP) and then either alter the website settings to load it or upload a custom .user.ini file specifying the extension=D:\path\to\wwwroot\somedir\extension.dll

Some composer install commands fail (such as Adldap/Adldap) if the interpreter running composer does not have the binary extension required for the library to operate loaded, even if the IIS invoked PHP interpreter does.

I ended up editing my deploy script to -dextension=D:\path\blah\my.dll and that resolved it temporarily however does not autoload additional libraries if the website variable or .user.ini file is updated. Is there any way the default composer extension can attempt to load additional configuration files to avoid this issue?

Errors when trying to download via SVN

Hi!
I find this extension the must for every php developer willing to deploy on Azure Site, but I'm finding some problems with dependencies: sometimes happens that a dependency could not be find under git and composer tries with SVN. In this case the deployment process is being flagged as successful but it actually isn't, 'cause Azure Site doesn't support the svn command.

Have you any ideas on how to introduce the svn command?

Thanks!

Deploying via ARM Template

Hi there,

I've been trying to install this extension via an ARM deployment template. I can get this to work fine with other extensions such as in this example:

https://github.com/davidebbo/AzureWebsitesSamples/blob/master/ARMTemplates/WebAppWithSiteExtension.json

But when I provide the value such as:

"resources": [   
                {
                    "apiVersion": "2015-08-01",
                    "name": "ComposerExtension",
                    "type": "siteextensions",
                    "dependsOn": [
                        "[variables('appName')]"
                    ],
                    "properties": {
                        "version": "0.5.3",
                        "feed_url": "https://www.siteextensions.net/api/v2/"
                    }
                }
            ]

I get an error saying that "ComposerExtension" could not be found. Any ideas why this is the case?

Composer write response like error

I am using kudu API to call composer commands and I use Invoke-RestMethod of powershell for that. The commad runs fine, but response returns like error.

image

So, I have tried with kudu console and really it writes red messages, it looks like error but it is not.

image

custom deployment not run when Composer extension is installed

Hi,

It looks like my custom deployment script is not running when this extension is installed.

I've got .deployment and deploy.cmd files in root of my repo.

During deployment only Composer deployment command is running.
After Composer extension deinstallation, custom script is running fine (except error about missing composer component)

.deployment

[config]
command = deploy.cmd

deploy.cmd

@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off

:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.6
:: ----------------------

:: Prerequisites
:: -------------

:: Verify node.js installed
where node 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
  echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
  goto error
)

:: Setup
:: -----

setlocal enabledelayedexpansion

SET ARTIFACTS=%~dp0%..\artifacts

IF NOT DEFINED DEPLOYMENT_SOURCE (
  SET DEPLOYMENT_SOURCE=%~dp0%.
)

IF NOT DEFINED DEPLOYMENT_TARGET (
  SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
)

IF NOT DEFINED NEXT_MANIFEST_PATH (
  SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest

  IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
    SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
  )
)

IF NOT DEFINED KUDU_SYNC_CMD (
  :: Install kudu sync
  echo Installing Kudu Sync
  call npm install kudusync -g --silent
  IF !ERRORLEVEL! NEQ 0 goto error

  :: Locally just running "kuduSync" would also work
  SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd
)
goto Deployment

:: Utility Functions
:: -----------------

:SelectNodeVersion

IF DEFINED KUDU_SELECT_NODE_VERSION_CMD (
  :: The following are done only on Windows Azure Websites environment
  call %KUDU_SELECT_NODE_VERSION_CMD% "%DEPLOYMENT_SOURCE%" "%DEPLOYMENT_TARGET%" "%DEPLOYMENT_TEMP%"
  IF !ERRORLEVEL! NEQ 0 goto error

  IF EXIST "%DEPLOYMENT_TEMP%\__nodeVersion.tmp" (
    SET /p NODE_EXE=<"%DEPLOYMENT_TEMP%\__nodeVersion.tmp"
    IF !ERRORLEVEL! NEQ 0 goto error
  )

  IF EXIST "%DEPLOYMENT_TEMP%\__npmVersion.tmp" (
    SET /p NPM_JS_PATH=<"%DEPLOYMENT_TEMP%\__npmVersion.tmp"
    IF !ERRORLEVEL! NEQ 0 goto error
  )

  IF NOT DEFINED NODE_EXE (
    SET NODE_EXE=node
  )

  SET NPM_CMD="!NODE_EXE!" "!NPM_JS_PATH!"
) ELSE (
  SET NPM_CMD=npm
  SET NODE_EXE=node
)

goto :EOF

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

:Deployment
echo Handling deployment.

:: 1. Install composer packages

  call composer install %COMPOSER_ARGS%

:: 3. Select node version
call :SelectNodeVersion

:: 4. Install npm packages
IF EXIST "%DEPLOYMENT_TARGET%\package.json" (
  pushd "%DEPLOYMENT_TARGET%"
  echo Running NPM Install
  call :ExecuteCmd !NPM_CMD! install
  IF !ERRORLEVEL! NEQ 0 goto error
  popd
)

:: 5. Run gulp transformations
IF EXIST "%DEPLOYMENT_TARGET%\gulpfile.js" (
  pushd "%DEPLOYMENT_TARGET%"
  echo Running Gulp Task
  call :ExecuteCmd .\node_modules\.bin\gulp
  IF !ERRORLEVEL! NEQ 0 goto error
  popd
)

:: 2. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_SOURCE%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
  IF !ERRORLEVEL! NEQ 0 goto error
)


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Post deployment stub
IF DEFINED POST_DEPLOYMENT_ACTION call "%POST_DEPLOYMENT_ACTION%"
IF !ERRORLEVEL! NEQ 0 goto error

goto end

:: Execute command routine that will echo out when error
:ExecuteCmd
setlocal
set _CMD_=%*
call %_CMD_%
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
exit /b %ERRORLEVEL%

:error
endlocal
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul

:exitSetErrorLevel
exit /b 1

:exitFromFunction
()

:end
endlocal
echo Finished successfully.

Composer packages installation fails

When deploying the example source code from GitHub, I end up getting following error (WAWS Composer site extension enabled):

Command: d:\home\SiteExtensions\ComposerExtension\Hooks\deploy.cmd
Using custom deployment setting for DEPLOYMENT_SOURCE custom value is 'web'.
Install Dependencies with Composer
Loading composer repositories with package information
Initializing PEAR repository http://pear.php.net
Installing dependencies
  - Installing pear-pear.php.net/mail_mime (1.8.9)
    Downloading
  - Installing pear-pear.php.net/mail_mimedecode (1.5.5)
    Downloading
  - Installing pear-pear.php.net/net_url2 (2.2.0)
    Downloading
  - Installing pear-pear.php.net/xml_util (1.3.0)
    Downloading
  - Installing pear-pear.php.net/console_getopt (1.4.0)
    Downloading
  - Installing pear-pear.php.net/structures_graph (1.1.0)
    Downloading
  - Installing pear-pear.php.net/archive_tar (1.3.16)
    Downloading
  - Installing pear-pear.php.net/pear (1.9.5)
    Downloading




  [UnexpectedValueException]                                                                                                                                                  
Fatal error: Uncaught exception 'Symfony\Component\Process\Exception\RuntimeException' with message 'Unable to kill the process' in phar://D:/home/SiteExtensions/ComposerExtension/Commands/composer.phar/vendor/symfony/process/Symfony/Component/Process/Process.php:803
  Failed to extract PEAR package D:\home\site\vendor/pear-pear.php.net/PEAR/PEAR-1.9.5.tgz to D:\home\site\vendor/pear-pear.php.net/PEAR. Reason: Unable to kill the process  
Stack trace:

#0 phar://D:/home/SiteExtensions/ComposerExtension/Commands/composer.phar/vendor/symfony/process/Symfony/Component/Process/Process.php(177): Symfony\Component\Process\Process->stop()

#1 [internal function]: Symfony\Component\Process\Process->__destruct()

#2 {main}

  thrown in phar://D:/home/SiteExtensions/ComposerExtension/Commands/composer.phar/vendor/symfony/process/Symfony/Component/Process/Process.php on line 803


  [Symfony\Component\Process\Exception\RuntimeException]  
  Unable to kill the process                              



install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [packages1] ... [packagesN]


Handling Basic Web Site deployment.
KuduSync.NET from: 'D:\home\site\repository\web' to: 'D:\home\site\wwwroot'
Deleting file: 'hostingstart.html'
Copying file: 'index.php'
Finished successfully.

Another useful information could be probably Ran For: 400 seconds
This seems to me like composer is timing out - possibly by changing the Kudu timeout setting SCM_COMMAND_IDLE_TIMEOUT=600 (as per here), but I haven't tested this yet.

Could you look into this please?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.