Skip to content

Build command fails when deploying to App Runner

0

Hello,

I'm having a problem deploying my Django application on AWS App Runner. Here are the details:

08-27-2024 03:18:56 PM [AppRunner] Successfully pulled your application source code.
08-27-2024 03:19:07 PM [AppRunner] Reading apprunner.yaml config file.
08-27-2024 03:19:08 PM [AppRunner] Successfully validate configuration file.
08-27-2024 03:19:09 PM [AppRunner] Starting source code build.
08-27-2024 03:20:42 PM [AppRunner] Failed to build your application source code. 

Reason: Failed to execute 'build' command.

Service used: AWS App Runner

Problem: Application fails to build source code.

here are the contents of my apprunner.yaml file:

version: 1.0
runtime: python311
build:
  commands:
    build:
      - pip install -r requirements.txt
run:
  runtime-version: 3.11.9
  command: sh startup.sh
  network:
    port: 8000

I use Django 4.2.15 and python 3.11.9

need help please!

asked a year ago1.5K views
2 Answers
1

Hello. I've had the same issue. I was trying to deploy a nodejs API from my github repo that has some python scripts in it. I kept getting that exact same error without any details as to why it's happening. After hours of debugging I found out that it was a file in my repo called .python-version . So for anyone facing this issue- make you remove that file and you shouldn't be seeing that error. I had that file to specify which python version to download so only downside is i had to remove it. Hope this helps anyone in the future.

answered a year ago
  • @Chris you're a life saver. Thanks man.

0

Hello.

The solution in the URL below seems to be solved by including it in "pre-run" instead of "build".
Please try it just to be sure.
https://repost.aws/questions/QUtR_3nFS4T3y56OHsNzEQ0w/app-runner-django-deployment-error-python-version3-11#ANg5eiaTNXRfynNNtgG7jB9A

What are you trying to install using "requirements.txt"?
It is possible that you are trying to install something that cannot be used with Python 3.11.9 and it is failing.

Also, the example described in the document below uses "pip3" instead of "pip" command, so please try that as well.
https://docs.aws.amazon.com/apprunner/latest/dg/config-file-examples.html

version: 1.0
runtime: python311
build:
  commands:
    build:
      - pip3 install -r requirements.txt
run:
  runtime-version: 3.11.9
  command: sh startup.sh
  network:
    port: 8000
EXPERT
answered a year ago
  • in the requirements.txt file I try to install the following dependencies:

    asgiref==3.8.1
    certifi==2024.7.4
    cffi==1.17.0
    charset-normalizer==3.3.2
    cryptography==43.0.0
    defusedxml==0.8.0rc2
    distlib==0.3.8
    Django==4.2.2
    django-templated-mail==1.1.1
    djangorestframework==3.15.2
    djangorestframework-simplejwt==5.3.1
    djoser==2.2.3
    filelock==3.15.4
    gunicorn==20.1.0
    idna==3.8
    oauthlib==3.2.2
    pillow==10.4.0
    platformdirs==4.2.2
    psycopg2==2.9.9
    pycparser==2.22
    PyJWT==2.9.0
    python-decouple==3.8
    python3-openid==3.2.0
    requests==2.32.3
    requests-oauthlib==2.0.0
    setuptools==73.0.1
    social-auth-app-django==5.4.2
    social-auth-core==4.5.4
    sqlparse==0.5.1
    tzdata==2024.1
    urllib3==2.2.2
    virtualenv==20.26.3
    whitenoise==6.4.0
    
  • Have you tried changing it to "pip3"?

    version: 1.0
    runtime: python311
    build:
      commands:
        build:
          - pip3 install -r requirements.txt
    run:
      runtime-version: 3.11.9
      command: sh startup.sh
      network:
        port: 8000
    

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.