INIT(api): add FastAPI application

- Initialize FastAPI project structure
- Add basic API configuration
This commit is contained in:
2025-12-01 14:34:20 +09:00
commit 615fe6e574
19 changed files with 1418 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
# Development Dockerfile for Joossam FastAPI OMR Grading Service
FROM python:3.11-slim
# 시스템 의존성 설치 (OpenCV용)
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1-mesa-glx \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Python 의존성 설치
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 개발용 의존성 추가
RUN pip install --no-cache-dir watchfiles
# 애플리케이션 코드 복사
COPY . .
EXPOSE 8000
# 헬스체크
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# 개발 서버 실행 (hot-reload 활성화)
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]

View File

@@ -0,0 +1,39 @@
# Production Dockerfile for Joossam FastAPI OMR Grading Service
FROM python:3.11-slim AS base
# 시스템 의존성 설치 (OpenCV용)
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1-mesa-glx \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Python 의존성 설치
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 애플리케이션 코드 복사
COPY . .
# 비루트 사용자 생성 및 전환
RUN addgroup --system --gid 1001 appgroup && \
adduser --system --uid 1001 --gid 1001 appuser && \
chown -R appuser:appgroup /app
USER appuser
EXPOSE 8000
ENV HOST=0.0.0.0
ENV PORT=8000
# 헬스체크
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

View File

@@ -0,0 +1,25 @@
services:
# Development Joossam FastAPI Application
app:
build:
context: ../../services/fastapi
dockerfile: ../../deploy/docker/Dockerfile.dev
container_name: joossam-app-dev
restart: unless-stopped
labels:
kompose.namespace: joossam
ports:
- 8001:8000
environment:
- ENV=development
networks:
- joossam-network
volumes:
- ../../services/fastapi:/app
command: uvicorn main:app --host 0.0.0.0 --port 8000 --reload
networks:
joossam-network:
driver: bridge
name: joossam-network-dev

View File

@@ -0,0 +1,23 @@
services:
# Production Joossam FastAPI Application
app:
image: joossam-app
build:
context: ../../services/fastapi
dockerfile: ../../deploy/docker/Dockerfile.prod
container_name: joossam-app-prod
restart: unless-stopped
labels:
kompose.namespace: joossam
ports:
- 8001:8000
environment:
- ENV=production
networks:
- joossam-network
networks:
joossam-network:
driver: bridge
name: joossam-network-prod