Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
79 lines (59 loc) · 2.1 KB
/
Copy pathDockerfile
File metadata and controls
79 lines (59 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# ============================================
# MHTI - Multi-stage Docker Build
# Caddy (reverse proxy) + FastAPI (API)
# ============================================
# Stage 1: Build frontend
FROM node:20-alpine AS frontend-builder
WORKDIR /app
COPY web/package*.json ./
RUN npm ci --silent
COPY web/ .
RUN npm run build
# Stage 2: Runtime environment
FROM python:3.11-slim AS runtime
LABEL org.opencontainers.image.title="MHTI"
LABEL org.opencontainers.image.description="Media metadata scraper with TMDB integration"
LABEL org.opencontainers.image.version="1.0.0"
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
DATA_DIR=/app/data
WORKDIR /app
# Install system dependencies + Caddy
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
gnupg \
debian-keyring \
debian-archive-keyring \
apt-transport-https \
&& curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg \
&& curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list \
&& apt-get update \
&& apt-get install -y caddy \
&& rm -rf /var/lib/apt/lists/*
# Install poetry
RUN pip install poetry --no-cache-dir
# Copy dependency files
COPY pyproject.toml poetry.lock* ./
# Install Python dependencies
RUN poetry config virtualenvs.create false && \
poetry install --only main --no-root --no-interaction --no-ansi && \
rm -rf ~/.cache/pypoetry
# Copy backend source code
COPY server/ ./server/
# Copy frontend build artifacts
COPY --from=frontend-builder /app/dist /app/static/
# Copy Caddy configuration
COPY Caddyfile /etc/caddy/Caddyfile
# Copy startup script
COPY start.sh /app/start.sh
RUN chmod +x /app/start.sh
# Create data directory
RUN mkdir -p /app/data && chmod 755 /app/data
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Expose ports
EXPOSE 8000
CMD ["/app/start.sh"]