Friday, 12 July 2024

python docker deployment

Run comand

 

 FROM python:3.9-slim
WORKDIR /app
COPY ai-quiz-service/requirements.txt .
COPY config/dev.env /app/.env
RUN pip install --no-cache-dir -r requirements.txt
COPY app/ app/
ENV PYTHONPATH=/app
EXPOSE 8088
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8088"]

 

docker build --build-arg ENV_FILE=app/config/dev.env -t myfastapi:dev .


# Use an official Python runtime as a parent image
FROM python:3.10

# Set the working directory in the container
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Define build argument for the environment file
ARG ENV_FILE

# Copy the environment file from the build context to the container
COPY ${ENV_FILE} /app/.env

# Make port 80 available to the world outside this container
EXPOSE 8088

# Ensure the PYTHONPATH includes the /app directory
ENV PYTHONPATH=/app

# Run app.py when the container launches
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8088"]
 

 

 

 

No comments:

Post a Comment