add docker file
parent
fbb9dc2031
commit
7dc9cf9144
@ -0,0 +1,50 @@
|
|||||||
|
# Use the official Python 3.11 image from the Docker Hub
|
||||||
|
FROM python:3.11-slim as builder
|
||||||
|
|
||||||
|
# Install Poetry
|
||||||
|
RUN pip install poetry
|
||||||
|
|
||||||
|
# Set environment variables for Poetry
|
||||||
|
ENV POETRY_NO_INTERACTION=1 \
|
||||||
|
POETRY_VIRTUALENVS_IN_PROJECT=1 \
|
||||||
|
POETRY_VIRTUALENVS_CREATE=1 \
|
||||||
|
POETRY_CACHE_DIR=/tmp/poetry_cache
|
||||||
|
|
||||||
|
# Set the working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy the Poetry configuration files
|
||||||
|
COPY pyproject.toml poetry.lock ./
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN poetry install --no-dev --no-root
|
||||||
|
|
||||||
|
# Use a new slim image for the runtime
|
||||||
|
FROM python:3.11-slim as runtime
|
||||||
|
|
||||||
|
# Install necessary tools for running the app, including `make`
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
make \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Set environment variables for Poetry
|
||||||
|
ENV POETRY_VIRTUALENVS_IN_PROJECT=1 \
|
||||||
|
PATH="/app/.venv/bin:$PATH"
|
||||||
|
|
||||||
|
# Copy Poetry installation from builder
|
||||||
|
COPY --from=builder /app/.venv /app/.venv
|
||||||
|
|
||||||
|
# Copy application files
|
||||||
|
COPY . /app/
|
||||||
|
|
||||||
|
# Delete Tests for production
|
||||||
|
RUN rm -rf /app/tests/
|
||||||
|
|
||||||
|
# Expose port for the application
|
||||||
|
EXPOSE 3005
|
||||||
|
|
||||||
|
# Set the working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Run `make run` as the entry point
|
||||||
|
CMD ["make", "run"]
|
||||||
@ -1,4 +1,5 @@
|
|||||||
import uvicorn
|
import uvicorn
|
||||||
|
from src.config import PORT
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
uvicorn.run("src.main:app", host="0.0.0.0", port=8081, reload=True)
|
uvicorn.run("src.main:app", host="0.0.0.0", port=int(PORT), reload=True)
|
||||||
|
|||||||
Loading…
Reference in New Issue