chore: update env and readme

This commit is contained in:
Sosokker 2025-06-28 00:05:27 +07:00
parent 43f37f7ad2
commit aec6e10f90
3 changed files with 30 additions and 22 deletions

View File

@ -1,36 +1,41 @@
# Start with the official Python 3.12 slim-buster image. # Use optimized Python + uv base image
# slim-buster is a good choice for production as it's smaller.
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
# Install the project into `/app` # Set work directory
WORKDIR /app WORKDIR /app
# Enable bytecode compilation # Avoid apt prompts and enable faster install
ENV DEBIAN_FRONTEND=noninteractive
ENV UV_COMPILE_BYTECODE=1 ENV UV_COMPILE_BYTECODE=1
# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy ENV UV_LINK_MODE=copy
# Install the project's dependencies using the lockfile and settings # Install `make` with minimal overhead
RUN apt-get update && \
apt-get install -y --no-install-recommends make && \
rm -rf /var/lib/apt/lists/*
# Copy lockfile and project config first for cache efficiency
COPY uv.lock pyproject.toml ./
# Install dependencies using cache mount
RUN --mount=type=cache,target=/root/.cache/uv \ RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --locked --no-install-project --no-dev uv sync --locked --no-install-project --no-dev
# Then, add the rest of the project source code and install it # Copy remaining project files
# Installing separately from its dependencies allows optimal layer caching COPY . .
COPY . /app
# Install project (with cache)
RUN --mount=type=cache,target=/root/.cache/uv \ RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-dev uv sync --locked --no-dev
# Place executables in the environment at the front of the path # Pre-create DB tables
RUN make create-tables
# Add local venv to PATH
ENV PATH="/app/.venv/Lib:$PATH" ENV PATH="/app/.venv/Lib:$PATH"
# Reset the entrypoint, don't invoke `uv` # Avoid `uv` entrypoint override
ENTRYPOINT [] ENTRYPOINT []
# Command to run the application # Start the FastAPI app with uvicorn
# Use uvicorn to run the FastAPI application. CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
# --host 0.0.0.0 is required to make the app accessible from outside the container
# --port 8000 to match the exposed port
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

View File

@ -9,11 +9,14 @@ PlainRAG is RAG application without LLM orchestration frameworks like Langchain
2. Run the following command to build and start the services: 2. Run the following command to build and start the services:
```bash ```bash
docker compose up db -d
make install-deps # or uv sync make install-deps # or uv sync
make create-tables make create-tables
make start make start
``` ```
Then navigate to [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
or or
```bash ```bash

View File

@ -19,9 +19,9 @@ services:
env_file: env_file:
- .env - .env
environment: environment:
- DB_USER=${DB_USER:-user} - POSTGRES_USER=${DB_USER:-user}
- DB_PASSWORD=${DB_PASSWORD:-password} - POSTGRES_PASSWORD=${DB_PASSWORD:-password}
- DB_NAME=${DB_NAME:-mydatabase} - POSTGRES_DB=${DB_NAME:-mydatabase}
volumes: volumes:
- db_data:/var/lib/postgresql/data - db_data:/var/lib/postgresql/data