-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (48 loc) · 2.25 KB
/
Copy pathDockerfile
File metadata and controls
65 lines (48 loc) · 2.25 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
# ── Stage 1: Build React frontend ────────────────────────────────────────────
FROM node:20-alpine AS frontend-build
LABEL stage="frontend-builder"
WORKDIR /app/frontend
# Cache deps separately from source
COPY frontend/package*.json ./
RUN npm ci --prefer-offline --ignore-scripts
COPY frontend/ ./
ARG REACT_APP_API_URL=/api
ENV REACT_APP_API_URL=$REACT_APP_API_URL
ENV DISABLE_ESLINT_PLUGIN=true
ENV CI=false
RUN npm run build \
&& find /app/frontend/build -name "*.map" -delete # strip source maps
# ── Stage 2: Backend + bundled static files (single-container) ───────────────
FROM python:3.12-slim
LABEL org.opencontainers.image.title="Internet Stability Tracker" \
org.opencontainers.image.description="Network monitoring — FastAPI + React in one container" \
org.opencontainers.image.version="3.3.0" \
org.opencontainers.image.source="https://github.com/manziosee/Internet-Stability-Tracker" \
org.opencontainers.image.licenses="MIT"
# Patch base-image CVEs and add curl for healthcheck + traceroute for network diagnostics
RUN apt-get update && apt-get upgrade -y --no-install-recommends \
&& apt-get install -y --no-install-recommends curl traceroute iputils-ping \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install Python deps (cached unless requirements.txt changes)
COPY backend/requirements.txt ./
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# Copy backend source
COPY backend/ ./
# Place the React build where FastAPI's StaticFiles middleware will serve it
COPY --from=frontend-build /app/frontend/build ./static
# Non-root user — drop privileges before running
RUN adduser --disabled-password --no-create-home --gecos "" appuser \
&& chown -R appuser:appuser /app
USER appuser
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=25s --retries=3 \
CMD curl -fs http://localhost:8000/health || exit 1
# 1 worker on Fly.io free tier (512 MB); scale via fly.toml [[vm]] for more
CMD ["uvicorn", "app.main:app", \
"--host", "0.0.0.0", \
"--port", "8000", \
"--workers", "1", \
"--log-level", "info", \
"--access-log"]