Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: How to use Custom PHP/Alpine image as running container ? #5054

Closed
1 of 4 tasks
abenevaut opened this issue Dec 3, 2024 · 1 comment
Closed
1 of 4 tasks

Comments

@abenevaut
Copy link

Describe your question

I build a custom docker image to run CI for a PHP Application. I'm looking the right way to use it inside azure pipelines.
Now, the image is correctly pulled and started ("resources" container too) but pipeline fails when trying to execute the first "script" task (named 'composer install' in following example).

Following, a pipeline example close as possible of mine:

trigger:
  branches:
    include:
      - dev

resources:
  containers:
    - container: azsql
      image: mcr.microsoft.com/azure-sql-edge
      name: sql-server
      hostname: sql-server
      ports:
        - 1433:1433
      env:
        ACCEPT_EULA: 1
        SA_PASSWORD: yourStrong(!)Password
        MSSQL_PID: Developer

stages:

  - stage: Test
    displayName: TestStage
    jobs:
      - job: TestPHPService
        pool:
          vmImage: 'ubuntu-latest'
        container:
          image: my.azurecr.io/my/alpine-img:latest
          endpoint: 'my-service-connection'
        services:
          azsql: azsql
        steps:

          - script: |
              composer -V
              composer validate --strict
              composer install --optimize-autoloader --no-interaction --prefer-dist
            displayName: 'composer install'
            workingDirectory: $(System.DefaultWorkingDirectory)

The output looks like:

Starting: composer install
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.246.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
exec /__a/externals/node/bin/node: no such file or directory
##[error]Exit code 1 returned from process: file name '/usr/bin/docker', arguments 'exec -i -u 1001  -w /home/vsts_azpcontainer f57d9b1f13acc1ae7fb4a68e67f1cf7883b4f535be69e03855f76e2942c6f16c /__a/externals/node/bin/node /__w/_temp/containerHandlerInvoker.js'.
Finishing: composer install

My image contains bash, nodejs & npm. I do not know with tool i missed.

Versions

🤷‍♂️ Version : 2.246.1 🤷‍♂️

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Operation system

No response

Version controll system

No response

Azure DevOps Server Version (if applicable)

No response

@abenevaut
Copy link
Author

I found this documentation https://learn.microsoft.com/en-us/azure/devops/pipelines/process/container-phases?view=azure-devops&tabs=windows#nonglibc-based-containers

Applied the label and added forgotten binaries in custom image, but still failing.

LABEL "com.azure.dev.pipelines.agent.handler.node.path"="/usr/bin/node"

RUN apk add --no-cache --virtual .pipeline-deps readline linux-pam \
      && apk add bash sudo shadow nodejs npm \
      && apk del .pipeline-deps \
      && rm -rf /var/cache/apk/*
##[error]Exit code 126 returned from process: file name '/usr/bin/docker', arguments 'exec -i -u 1001  -w /home/vsts_azpcontainer c81f6c549eb45156d0aa0cb22df7266f88dca562ab488fddabd4d80c4e1fcea1 /usr/local/bin/node /__w/_temp/containerHandlerInvoker.js'.

In documentation a sentence say "If you depend on any in-box or Marketplace tasks, also supply the binaries they require.", i have no docker task or script in my pipeline, this is probably related too the agent and custom image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant