Hello,
I’m trying to deploy a FastAPI app using Github Actions. I can successfully deploy it without using the --prebuilt
tag. However, I wonder if having --prebuilt
is best practice? it seems to me that it prevents the whole source code to be deployed but only the new changes? I’m not quite sure but apparently Vercel can’t detect .vercel/output
folder even though it looks like vercel build
does create it.
Command
vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
Error
Error: ENOENT: no such file or directory, lstat '/vercel/path0/.vercel/output/builds.json'
Project Setup
vercel.json
{
"version": 2,
"builds": [
{
"src": "app/main.py",
"use": "@vercel/python"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "app/main.py"
}
],
"outputDirectory": ".vercel/output"
}
ci_cd_pipeline.yml
name: Run Tests and Deploy to Vercel
on:
push:
branches:
- main
jobs:
run_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11.5'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
run: |
pytest
# deploy to vercel
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
Full Log
Run vercel build --token=***
vercel build --token=***
shell: /usr/bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.11.5/x64
PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.5/x64/lib/pkgconfig
Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.5/x64
Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.5/x64
Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.5/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.5/x64/lib
Vercel CLI 39.1.2
WARN! Due to `builds` existing in your configuration file, the Build and Development Settings defined in your Project Settings will not apply. Learn More: https://vercel.link/unused-build-settings
Installing required dependencies...
Build Completed in .vercel/output [4s]
Run vercel deploy --prebuilt --token=***
vercel deploy --prebuilt --token=***
shell: /usr/bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.11.5/x64
PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.5/x64/lib/pkgconfig
Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.5/x64
Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.5/x64
Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.5/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.5/x64/lib
Vercel CLI 39.1.2
Retrieving project…
Deploying redhorseacademy-projects/fastapi_demo
Uploading [--------------------] (0.0B/8.4MB)
(node:1865) MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners added to [AbortSignal]. Use events.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
Uploading [=====---------------] (2.1MB/8.4MB)
Uploading [==========----------] (4.2MB/8.4MB)
Uploading [===============-----] (6.3MB/8.4MB)
Uploading [====================] (8.4MB/8.4MB)
Inspect: https://vercel.com/redhorseacademy-projects/fastapi_demo/6e2Q9vtYnY25YHu7rtBXviBYiQUb [10s]
Preview: https://fastapidemo-juxg522yb-redhorseacademy-projects.vercel.app [10s]
Queued
Building
Error: ENOENT: no such file or directory, lstat '/vercel/path0/.vercel/output/builds.json'
https://fastapidemo-juxg522yb-redhorseacademy-projects.vercel.app
Error: Process completed with exit code 1.
Am I missing something? Since it’s not an officially supported framework, do I need a custom/different configuration for FastAPI?
UPDATE 1
Well, to make matters worse, I tried building/deploying locally using Vercel CLI and it turns out I also run into the same issue despite the .vercel/output/builds.json
being in the local directory.
(fastapi_env) (base) redhorseacademyPC:fastapi_demo redhorseacademy$ vercel build
Vercel CLI 39.1.2
WARN! Due to `builds` existing in your configuration file, the Build and Development Settings defined in your Project Settings will not apply. Learn More: https://vercel.link/unused-build-settings
Installing required dependencies...
✅ Build Completed in .vercel/output [9s]
(fastapi_env) (base) redhorseacademyPC:fastapi_demo redhorseacademy$ vercel deploy --prebuilt --archive=tgz
Vercel CLI 39.1.2
🔍 Inspect: https://vercel.com/redhorseacademy-projects/fastapi_demo/D7sF6esFWwpRLEbhCRdibYFNKyCn [6m]
✅ Preview: https://fastapidemo-38s604pe3-redhorseacademy-projects.vercel.app [6m]
Error: ENOENT: no such file or directory, lstat '/vercel/path0/.vercel/output/builds.json'
.vercel/output/builds.json
{
"//": "This file was generated by the `vercel build` command. It is not part of the Build Output API.",
"target": "preview",
"argv": [
"/usr/local/bin/node",
"/usr/local/bin/vercel",
"build"
],
"builds": [
{
"require": "@vercel/python",
"requirePath": "/usr/local/lib/node_modules/vercel/node_modules/@vercel/python/dist/index.js",
"apiVersion": 3,
"src": "app/main.py",
"use": "@vercel/python"
}
]
}
Any help is appreciated