Complete the code to specify the base image for a FastAPI Docker container.
FROM [1]The base image python:3.12-slim is suitable for FastAPI apps using Python 3.12.
Complete the code to copy the application files into the Docker image.
COPY [1] /appCopying . copies all files from the current directory into the image's /app folder.
Fix the error in the command to install dependencies inside the Dockerfile.
RUN pip install [1] -r requirements.txtThe correct flag to specify a requirements file is -r or --requirement. The --upgrade flag upgrades packages but does not specify the requirements file.
Fill both blanks to expose the correct port and run the FastAPI app with uvicorn.
EXPOSE [1] CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "[2]"]
FastAPI by default runs on port 8000. Exposing and running on the same port ensures accessibility.
Fill all three blanks to create a Dockerfile snippet that sets the working directory, copies files, and installs dependencies.
WORKDIR [1] COPY [2] . RUN pip install -r [3]
Setting /app as working directory, copying current directory files, and installing from requirements.txt is standard practice.