#deploying fastapi with docker

1 messages · Page 1 of 1 (latest)

white falcon
#

Can't figure out how to make the app listen when deployed and assigned an url to. Works perfect when runned locally.

dockerfile:

FROM python:3.11.6

# Set working directory in the container
WORKDIR /baseApp

# Copy the contents of the scraper directory to the container's /app directory
COPY . /baseApp

# Install project dependencies
COPY requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt

# Expose the port that FastAPI will run on
EXPOSE 8000

# Command to run the FastAPI application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]```
blazing lanternBOT
#

Project ID: N/A

wraith dragonBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

solemn cloud
#

change your CMD to this

CMD uvicorn main:app --host 0.0.0.0 --port $PORT
wraith dragonBOT