can't access fast api
kanhaiya0999
TRIALOP

2 years ago

hi i have created a api with fast api and i have hosted this on railway and the deployments is finish successful and i also have add port 80 in railway env variable and also have add the variable inside my fast Api buy still can't access. getting server error

21 Replies

kanhaiya0999
TRIALOP

2 years ago

na


2 years ago

Please share your deployment logs


kanhaiya0999
TRIALOP

2 years ago

now its crashed
File "/opt/venv/lib/python3.11/site-packages/cv2/init.py", line 153, in bootstrap

nativemodule = importlib.importmodule("cv2")

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/root/.nix-profile/lib/python3.11/importlib/init.py", line 126, in import_module

return bootstrap.gcd_import(name[level:], package, level)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ImportError: libGL.so.1: cannot open shared object file: No such file or directory


kanhaiya0999
TRIALOP

2 years ago

the code is working fine in my virtual env on my local pc


2 years ago

Can you also share your requirements.txt file?


2 years ago

Also, are you using nixpacks to build, or a Dockerfile?


kanhaiya0999
TRIALOP

2 years ago

i just create .python-version file and mention my version 3.11 and start building my project already have main.py file and in build command its use this


2 years ago

For deploying on Railway, you will need to use a Dockerfile. The error above is related to libGL not being available in you nixpacks deployment.


kanhaiya0999
TRIALOP

2 years ago

i dont know how to create it i ever touch docker yet how to do this? can you give me ?


kanhaiya0999
TRIALOP

2 years ago

i want to use python 11 then requirements.txt then main.py


kanhaiya0999
TRIALOP

2 years ago

so can you create a file for me


2 years ago

Can you share your git repo?


kanhaiya0999
TRIALOP

2 years ago

sorry its my client project


kanhaiya0999
TRIALOP

2 years ago

chat gpt create this is this is right?

Use an official Python runtime as a parent image

FROM python:3.11

Set the working directory in the container

WORKDIR /usr/src/app

Copy the current directory contents into the container at /usr/src/app

COPY . .

Install any needed packages specified in requirements.txt

RUN pip install --no-cache-dir -r requirements.txt

Make port 80 available to the world outside this container

EXPOSE 80

Define environment variable

ENV NAME World

Run main.py when the container launches

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]


2 years ago

That should work as a starting point, yes.


kanhaiya0999
TRIALOP

2 years ago

what name should i give to docker file?


2 years ago

Dockerfile


kanhaiya0999
TRIALOP

2 years ago

.Dockerfile?


2 years ago

Just Dockerfile no dot, no file extension.


kanhaiya0999
TRIALOP

2 years ago

i have main.py so its should be main:main


2 years ago

If your entrypoint into the application is a function called "app" then you would use app… if it is a declaration of main, you would use main


Loading...