-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
68 lines (52 loc) · 1.8 KB
/
Dockerfile
File metadata and controls
68 lines (52 loc) · 1.8 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
# Taxomind API - Production Dockerfile for Coolify
FROM python:3.13-slim AS builder
WORKDIR /app
# Keep container output unbuffered
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# Install build dependencies for Python wheels
RUN apt-get update && apt-get install -y \
--no-install-recommends \
build-essential \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# Create virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Copy only production requirements
COPY requirements-prod.txt .
# Install production dependencies only
RUN pip install --upgrade pip setuptools wheel && \
pip install --no-cache-dir -r requirements-prod.txt
FROM python:3.13-slim AS runtime
WORKDIR /app
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PATH="/opt/venv/bin:$PATH" \
PYTHONPATH=/app/src
# Runtime-only system dependency
RUN apt-get update && apt-get install -y \
--no-install-recommends \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# Copy prebuilt virtualenv from builder stage
COPY --from=builder /opt/venv /opt/venv
# Copy application files
COPY src/ ./src/
COPY conf/ ./conf/
COPY scripts/ ./scripts/
COPY pyproject.toml ./pyproject.toml
# Create data folders for runtime; mount /app/data as a volume in Coolify for persistence
RUN mkdir -p \
/app/data/01_raw \
/app/data/02_intermediate \
/app/data/03_primary \
/app/data/06_training \
/app/data/07_model_output \
/app/data/08_temp_training \
/app/data/09_job_store
# Health check endpoint
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import os,urllib.request; port=os.getenv('PORT','3000'); urllib.request.urlopen(f'http://localhost:{port}/health').read()"
# Start server in production mode
CMD ["python", "scripts/start_api_prod.py"]