microsoft / Oryx

Build your repo automatically.
Other
768 stars 176 forks source link

Ory build fails with: `-m: command not found` #2542

Open bblommers opened 1 day ago

bblommers commented 1 day ago

Bug Report

Using the full-debian-bullseye docker image, I'm not able to build a simple Python app, as it fails with the message: -m: command not found

Build log

Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues

Oryx Version: 0.2.20240520.1, Commit: c261287ed35c6c62b5ecf3174cda270495abb127, ReleaseTagName: 20240520.1

Build Operation ID: 7f5f7ecc72eaec89
OS Type           : buster
Image Type        : full

Detecting platforms...
Detected following platforms:
  python: 3.11.7
Version '3.11.7' of platform 'python' is not installed. Generating script to install it...

Source directory     : /repo
Destination directory: /repo

Downloading and extracting 'python' version '3.11.7' to '/tmp/oryx/platforms/python/3.11.7'...
Detected image debian flavor: buster.
Downloaded in 53 sec(s).
Verifying checksum...
Extracting contents...
performing sha512 checksum for: python...
Done in 55 sec(s).

Python Version: 
Creating directory for command manifest file if it does not exist
Removing existing manifest file
Python Virtual Environment: pythonenv3.11
Creating virtual environment...
/tmp/BuildScriptGenerator/b4cb977cf0e847f8b07cb60454c1bd7c/build.sh: line 266: -m: command not found

Reproduction steps

Start the oryx image:

docker pull mcr.microsoft.com/oryx/build:full-debian-bullseye
docker run --rm -it --entrypoint bash mcr.microsoft.com/oryx/build:full-debian-bullseye

Create a simple app:

mkdir /repo
cd /repo
echo "flask" > requirements.txt
cat <<EOT >> app.py
from flask import Flask, make_response
from flask import Flask, make_response
import sys

app = Flask(__name__)

@app.route('/')
def index():
    version = sys.version_info
    response = make_response(f"Hello World, I am Python {version.major}.{version.minor}", 200)
    response.mimetype = "text/plain"
    return response

if __name__ == '__main__':
    app.run(debug=True)
EOT

Run the build process:

oryx build --platform python --platform-version 3.11.7 /repo --output /repo

Debug

The relevant lines in the build script, what's actually causing the error -m command not found:

   261      echo Creating virtual environment...
   262  
   263      CreateVenvCommand="$python -m $VIRTUALENVIRONMENTMODULE $VIRTUALENVIRONMENTNAME $VIRTUALENVIRONMENTOPTIONS"
   264      echo "BuildCommands=$CreateVenvCommand" >> "$COMMAND_MANIFEST_FILE"
   265  
   266      $python -m $VIRTUALENVIRONMENTMODULE $VIRTUALENVIRONMENTNAME $VIRTUALENVIRONMENTOPTIONS
   267  
   268      echo Activating virtual environment...
   269      printf %s " , $ActivateVenvCommand" >> "$COMMAND_MANIFEST_FILE"
   270      ActivateVenvCommand="source $VIRTUALENVIRONMENTNAME/bin/activate"
   271      source $VIRTUALENVIRONMENTNAME/bin/activate

So it looks like the variable $python is not set.

This problem also occurs with the full-debian-buster image.

When running this against the latest image, I ran into https://github.com/microsoft/Oryx/issues/2162, which is why I attempted it using the newer buster/bullseye images.

bblommers commented 1 day ago

@sarsharma Hope you don't mind me tagging you explicitly. It looks like there is supposed to be a GithubAction that automatically assigns you, but that currently fails: https://github.com/microsoft/Oryx/actions/runs/11835777845/job/32979270835

sarsharma commented 19 hours ago

Hi @bblommers Can you please check if the issue still persists if you try with these new build images

mcr.microsoft.com/oryx/build:github-actions-debian-bookworm-20241021.3 mcr.microsoft.com/oryx/build:github-actions-debian-bullseye-20241021.3

Please note that buster based images and build:full-debian-bullseye tag are no longer being maintained. I will update the docs accordingly. Thanks

bblommers commented 18 hours ago

Hi @sarsharma, thank you for the reply - I can confirm that it does work with both the images you mentioned.

Is there any documentation on what each tagged build contains? A tag called github-actions.. sounds like it is meant to only be used in Github Actions, but are there any limitations/problems with using it locally?