forked from JamsheerJabbar/Hackathon_backend_deriv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (30 loc) · 1.29 KB
/
Dockerfile
File metadata and controls
41 lines (30 loc) · 1.29 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
# DerivSQL / NL2SQL Pipeline - Dockerfile for ECS Fargate
# Python 3.11 slim base for smaller image
FROM python:3.11-slim
# Prevent Python from writing pyc and buffering stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
WORKDIR /app
# Install system dependencies (e.g. for sentence-transformers if needed)
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Copy dependency file first for better layer caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY app/ ./app/
COPY frontend/ ./frontend/
# Create non-root user for ECS security best practice
RUN addgroup --system appgroup && adduser --system --ingroup appgroup appuser \
&& chown -R appuser:appgroup /app
USER appuser
# Expose the port the app runs on (matches main.py uvicorn port)
EXPOSE 8080
# Health check for ECS Fargate target group / container health
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health')" || exit 1
# Run FastAPI with uvicorn
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"]