mirror of
https://github.com/nethunterzist/trendyol-analiz
synced 2026-07-01 01:17:04 +00:00
Coolify remaps volume mounts to its own managed directories, so ./categories was mapped to an empty dir instead of the repo data. Changes: - Backend build context changed to repo root (.) so categories/ is accessible - Dockerfile copies categories into /data/initial-categories/ - startup.sh seeds /data/categories from bundled data if empty - Removed categories volume mount (reports still persisted via volume) - Added root .dockerignore (categories NOT excluded) - Updated CI workflow to match new build context Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
58 lines
1.6 KiB
Docker
58 lines
1.6 KiB
Docker
FROM python:3.11-slim
|
|
|
|
# Metadata
|
|
LABEL maintainer="Trendyol Product Dashboard"
|
|
LABEL description="FastAPI backend for Trendyol product analytics"
|
|
|
|
WORKDIR /app
|
|
|
|
# Install system dependencies
|
|
# - libpq-dev: PostgreSQL client library for psycopg2
|
|
# - curl: Health check and debugging
|
|
RUN apt-get update && apt-get install -y \
|
|
libpq-dev \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements first (Docker layer caching)
|
|
# Build context is repo root, so path is backend/
|
|
COPY backend/requirements.txt .
|
|
|
|
# Install Python dependencies
|
|
RUN pip install --no-cache-dir --upgrade pip && \
|
|
pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code from backend/
|
|
COPY backend/ .
|
|
|
|
# Copy categories data (bundled into image for Coolify deployment)
|
|
COPY categories/ /data/initial-categories/
|
|
|
|
# Create data directories with proper permissions
|
|
RUN mkdir -p /data/categories /data/reports && \
|
|
chmod -R 755 /data
|
|
|
|
# Make startup script executable (before switching to non-root user)
|
|
RUN chmod +x startup.sh
|
|
|
|
# Create non-root user for security
|
|
RUN useradd -m -u 1001 appuser && \
|
|
chown -R appuser:appuser /app /data
|
|
USER appuser
|
|
|
|
# Expose backend port
|
|
EXPOSE 8001
|
|
|
|
# Health check configuration
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=5 \
|
|
CMD curl -f http://localhost:8001/health || exit 1
|
|
|
|
# Environment variables (can be overridden at runtime)
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
DATABASE_URL=postgresql://postgres:trendyol123@postgres:5432/trendyol_db \
|
|
CATEGORIES_DIR=/data/categories \
|
|
REPORTS_DIR=/data/reports
|
|
|
|
# Start with migration script
|
|
CMD ["./startup.sh"]
|