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

ERROR: Failed to build your application source code. Reason: Failed to execute 'pre_build' command. #57

Open
anauecuri opened this issue Jan 8, 2025 · 0 comments

Comments

@anauecuri
Copy link

Hi everyone. I created a service in AWS apprunner and I am trying to deploy a python application using the python311 runtime. Whenever I tried to deploy using the code-based approach I got the error Failed to build your application source code. Reason: Failed to execute 'pre_build' command.
When I build as a docker image pulling from ECR the deployment is successful.

This is my GitHub actions pipeline:

name: Deploy to App Runner

on:
  push:
    branches: [ccl-develop] # Trigger workflow on git push to ccl-develop branch
  workflow_dispatch: # Allow manual invocation of the workflow

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read

    steps:
      # OIDC Assume Role
      - name: Configure AWS Credentials
        id: configure-aws-credentials
        uses: aws-actions/configure-aws-credentials@v3
        with:
          role-to-assume: ${{ vars.OIDC_ROLE }}
          aws-region: us-east-1

      # Deploy to App Runner
      - name: Deploy to App Runner
        id: deploy-apprunner
        uses: awslabs/amazon-app-runner-deploy@main
        with:
          service: ${{ vars.SERVICE_NAME }}
          source-connection-arn: ${{ vars.SOURCE_CONNECTION_ARN }}
          repo: https://github.com/${{ github.repository }}
          branch: ${{ github.ref }}
          runtime: PYTHON_311
          build-command: "yum --version || echo 'yum not found' && yum search gdal || echo 'gdal not found'"
          start-command: uvicorn app.main:app --host 0.0.0.0 --port 8000
          port: 8000
          region: us-east-1
          cpu: 1
          memory: 2
          wait-for-service-stability-seconds: 600
          copy-env-vars: |
            SERVER_PORT
            CITIES_API_AIRTABLE_KEY
            AIRTABLE_BASE_ID
          copy-secret-env-vars: |
            SECRET_ENV
          instance-role-arn: ${{ vars.INSTANCE_ROLE_ARN }}
          tags: |
            { "env": "test" }
        env:
          SERVER_PORT: 8000
          SECRET_ENV: secret_env
          CITIES_API_AIRTABLE_KEY: ${{ secrets.CITIES_API_AIRTABLE_KEY }}
          AIRTABLE_BASE_ID: ${{ vars.AIRTABLE_BASE_ID }}

      # Log App Runner URL
      - name: Log App Runner URL
        run: | 
          echo "App Runner URL: ${{ steps.deploy-apprunner.outputs.service-url }}"

This is the apprunner log after its execution:

01-08-2025 11:00:29 AM [AppRunner] Deployment with ID : a49e3b46e6a44382959bb20d0cbb15d1 started. Triggering event : SERVICE_CREATE
01-08-2025 11:00:29 AM [AppRunner] Deployment Artifact: [Repo Type: Source], [Repository: MASKED], [Branch: ccl-develop], [SourceDirectory: /]
01-08-2025 11:01:20 AM [AppRunner] Creating pipeline for automatic deployments.
01-08-2025 11:01:20 AM [AppRunner] Successfully created pipeline for automatic deployments.
01-08-2025 11:01:21 AM [AppRunner] Pulling source code from GITHUB Repository ( MASKED).
01-08-2025 11:01:23 AM [AppRunner] Successfully pulled your application source code.
01-08-2025 11:01:24 AM [AppRunner] Successfully validate configuration file.
01-08-2025 11:01:25 AM [AppRunner] Starting source code build.
01-08-2025 11:02:09 AM [AppRunner] Failed to build your application source code. Reason: Failed to execute 'pre_build' command.
01-08-2025 11:02:13 AM [AppRunner] Deployment with ID : a49e3b46e6a44382959bb20d0cbb15d1 failed.

Does anyone know what might be the issue?

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

No branches or pull requests

1 participant