Move to uv/pyproject and overhaul project structure

This commit is contained in:
Keannu Christian Bernasol 2025-09-01 02:10:28 +08:00
commit fbb76f8196
26 changed files with 1981 additions and 0 deletions

41
Dockerfile Normal file
View file

@ -0,0 +1,41 @@
# Stage 1: Builder
FROM python:3.13.7-slim AS builder
# Install uv binary from its official docker repository
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# Install OS-level dependencies(needed for compiling python packages)
RUN apt-get update && apt-get install -y --no-install-recommends \
curl build-essential && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy dependency management files
# (Only pyproject.toml and uv.lock file is needed to replicate the environment))
COPY pyproject.toml uv.lock /app/
# Use uv to install all project dependenies in a virtual environment
RUN uv sync --frozen --compile-bytecode
# Stage 2: Runtime
FROM python:3.13.7-slim AS runtime
# Environment variables
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
WORKDIR /app
# Copy the virtual environment from the builder stage
COPY --from=builder /app /app
# Add the virtual environments binary directory to PATH
ENV PATH="/app/.venv/bin:$PATH"
# Copy project files
COPY . /app/
# Expose Django's default port
EXPOSE 8000
ENTRYPOINT [ "/app/.docker/start.sh" ]