-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (48 loc) · 2.08 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (48 loc) · 2.08 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
# syntax=docker/dockerfile:1
# ---------------------------------------------------------------------------
# Stage 1: build the React/Vite frontend into static assets.
# ---------------------------------------------------------------------------
FROM node:20-slim AS frontend
WORKDIR /frontend
# Install deps first for better layer caching.
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build
# Produces /frontend/dist
# ---------------------------------------------------------------------------
# Stage 2: Python runtime that serves both the static frontend and the API.
# SPISEA itself is NOT installed here; its source tree is bind-mounted from
# CFS at runtime and added to PYTHONPATH by docker-entrypoint.sh.
# ---------------------------------------------------------------------------
FROM python:3.11-slim AS runtime
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
SPISEA_WEB_STATIC_DIR=/app/static \
SPISEA_WEB_ISO_DIR=/cache/iso
# Build tools some scientific wheels (e.g. parts of the COSMIC stack) may need.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
gfortran \
git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install Python dependencies first for caching.
COPY backend/requirements.txt backend/requirements-spisea.txt ./
RUN pip install --no-cache-dir -r requirements.txt -r requirements-spisea.txt
# Application code and built frontend.
COPY backend/app ./app
COPY --from=frontend /frontend/dist ./static
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# SPIN runs the container as an arbitrary NERSC UID/GID (required for CFS
# mounts). Make the app tree group/world readable and the cache dir writable
# regardless of which UID the pod is assigned.
RUN mkdir -p /cache/iso \
&& chmod -R go=rX /app \
&& chmod -R 0777 /cache
EXPOSE 8000
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]