Major Features: - ✅ Multi-tenant architecture (tenant isolation) - ✅ Employee CRUD with lifecycle management (onboarding/offboarding) - ✅ Department tree structure with email domain management - ✅ Company info management (single-record editing) - ✅ System functions CRUD (permission management) - ✅ Email account management (multi-account per employee) - ✅ Keycloak SSO integration (auth.lab.taipei) - ✅ Redis session storage (10.1.0.254:6379) - Solves Cookie 4KB limitation - Cross-system session sharing - Sliding expiration (8 hours) - Automatic token refresh Technical Stack: Backend: - FastAPI + SQLAlchemy - PostgreSQL 16 (10.1.0.20:5433) - Keycloak Admin API integration - Docker Mailserver integration (SSH) - Alembic migrations Frontend: - Next.js 14 (App Router) - NextAuth 4 with Keycloak Provider - Redis session storage (ioredis) - Tailwind CSS Infrastructure: - Redis 7 (10.1.0.254:6379) - Session + Cache - Keycloak 26.1.0 (auth.lab.taipei) - Docker Mailserver (10.1.0.254) Architecture Highlights: - Session管理由 Keycloak + Redis 統一控制 - 支援多系統 (HR/WebMail/Calendar/Drive/Office) 共享 session - Token 自動刷新,異質服務整合 - 未來可無縫遷移到雲端 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
60 lines
1.7 KiB
Docker
60 lines
1.7 KiB
Docker
# ============================================================================
|
|
# HR Portal Backend Dockerfile
|
|
# FastAPI + Python 3.11 + PostgreSQL
|
|
# ============================================================================
|
|
|
|
FROM python:3.11-slim as base
|
|
|
|
# 設定環境變數
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1
|
|
|
|
# 設定工作目錄
|
|
WORKDIR /app
|
|
|
|
# 安裝系統依賴
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
gcc \
|
|
postgresql-client \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# ============================================================================
|
|
# Builder Stage - 安裝 Python 依賴
|
|
# ============================================================================
|
|
FROM base as builder
|
|
|
|
# 複製需求檔案
|
|
COPY requirements.txt .
|
|
|
|
# 安裝 Python 依賴
|
|
RUN pip install --user --no-warn-script-location -r requirements.txt
|
|
|
|
# ============================================================================
|
|
# Runtime Stage - 最終映像
|
|
# ============================================================================
|
|
FROM base
|
|
|
|
# 從 builder 複製已安裝的套件
|
|
COPY --from=builder /root/.local /root/.local
|
|
|
|
# 確保 scripts 在 PATH 中
|
|
ENV PATH=/root/.local/bin:$PATH
|
|
|
|
# 複製應用程式碼
|
|
COPY . /app
|
|
|
|
# 創建日誌目錄
|
|
RUN mkdir -p /app/logs
|
|
|
|
# 暴露端口
|
|
EXPOSE 8000
|
|
|
|
# 健康檢查
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
|
CMD python -c "import httpx; httpx.get('http://localhost:8000/health', timeout=5.0)" || exit 1
|
|
|
|
# 啟動命令
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4"]
|