Issues Deploying FastAPI
ozeitis
PROOP

a year ago

Hey guys below is my code and Procfile, I get below error when deploying my code from github, what am I doing wrong?

Error

Error: Invalid value for '--port': '$PORT' is not a valid integer.

Usage: uvicorn [OPTIONS] APP

Try 'uvicorn --help' for help.

Procfile
web: uvicorn main:app --host 0.0.0.0 --port $PORT

Code

from fastapi import FastAPI, HTTPException
from pydantic import BaseModel, HttpUrl
from playwright.async_api import async_playwright
import base64
import tempfile
import os
from PyPDF2 import PdfReader, PdfMerger
from typing import List
import axiom_py
from axiom_py.logging import AxiomHandler
import logging
from google import genai
import json
from langfuse.decorators import observe, langfuse_context
from langfuse import Langfuse

# Set up Axiom client
axiom_client = axiom_py.Client(
    token="xxxxxx",
    org_id="xxxxxx"
)

# Set up logger
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
axiom_handler = AxiomHandler(axiom_client, "trigger")
logger.addHandler(axiom_handler)

# Add environment variable setup
os.environ["LANGFUSE_PUBLIC_KEY"] = "xxxxxx"  # Use your public key here
os.environ["LANGFUSE_SECRET_KEY"] = "xxxxxx"
os.environ["LANGFUSE_HOST"] = "https://us.cloud.langfuse.com"

# Initialize Langfuse after setting environment variables
langfuse = Langfuse()  # It will automatically pick up the environment variables

# Initialize Gemini client
genai_client = genai.Client(
    api_key="xxxxxx"  # Replace with your actual Gemini API key
)

app = FastAPI()

class PDFInfo(BaseModel):
    filename: str
    url: HttpUrl

class PDFInfoList(BaseModel):
    pdf_infos: List[PDFInfo]

... routes here ...
Solved

6 Replies

ozeitis
PROOP

a year ago

458d0e37-58b6-4785-a315-8a57258ba6f6


brody
EMPLOYEE

a year ago

you're using a dockerfile so a procfile isnt used at all, you're actually setting your start command via the service settings, so please read this -


ozeitis
PROOP

a year ago

I feel so stupid, idk where that docker file came from, I did not even notice it my bad


ozeitis
PROOP

a year ago

Thanks!


brody
EMPLOYEE

a year ago

nothing wrong with the dockerfile, you just need to set the correct start command 🙂


brody
EMPLOYEE

a year ago

!s


Status changed to Solved brody 12 months ago


Loading...