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
Project ID:
N/A
na
Please share your deployment logs
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
Can you also share your requirements.txt file?
Also, are you using nixpacks to build, or a Dockerfile?
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
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.
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
Can you share your git repo?
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"]
That should work as a starting point, yes.
what name should i give to docker file?
Dockerfile
.Dockerfile?
Just
Dockerfile
no dot, no file extension.i have main.py so its should be main:main
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