can't access fast api

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
17 Replies
Percy
Percy8mo ago
Project ID: N/A
kanhaiya lal bohra
na
MantisInABox
MantisInABox8mo ago
Please share your deployment logs
kanhaiya lal bohra
now its crashed File "/opt/venv/lib/python3.11/site-packages/cv2/init.py", line 153, in bootstrap native_module = importlib.import_module("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 the code is working fine in my virtual env on my local pc
MantisInABox
MantisInABox8mo ago
Can you also share your requirements.txt file? Also, are you using nixpacks to build, or a Dockerfile?
kanhaiya lal bohra
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
MantisInABox
MantisInABox8mo 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.
kanhaiya lal bohra
i dont know how to create it i ever touch docker yet how to do this? can you give me ? i want to use python 11 then requirements.txt then main.py so can you create a file for me
MantisInABox
MantisInABox8mo ago
Can you share your git repo?
kanhaiya lal bohra
sorry its my client project 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"]
MantisInABox
MantisInABox8mo ago
That should work as a starting point, yes.
kanhaiya lal bohra
what name should i give to docker file?
MantisInABox
MantisInABox8mo ago
Dockerfile
kanhaiya lal bohra
.Dockerfile?
MantisInABox
MantisInABox8mo ago
Just Dockerfile no dot, no file extension.
kanhaiya lal bohra
i have main.py so its should be main:main
MantisInABox
MantisInABox8mo 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
Want results from more Discord servers?
Add your server