Skip to content

Commit cc2e677

Browse files
committed
feat: Use container mount and add to compose
1 parent 9d40a32 commit cc2e677

3 files changed

Lines changed: 14 additions & 15 deletions

File tree

compose.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,17 @@ services:
2525
user: "${UID}:${GID}"
2626
command: python -m simulator.diffraction_generator --config /app/configs/simulator.yaml
2727
restart: "no"
28+
29+
ui:
30+
build:
31+
context: .
32+
dockerfile: docker/ui.Dockerfile
33+
ports:
34+
- "7860:7860"
35+
volumes:
36+
- ./data/:/data/:ro
37+
- ./src/ui/models/:/app/models/:ro
38+
environment:
39+
- PYTHONUNBUFFERED=1
40+
- PORT=7860
41+
restart: unless-stopped

docker/ui.Dockerfile

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,28 @@ FROM node:18-alpine AS frontend-builder
44

55
WORKDIR /app/frontend
66

7-
# Copy frontend package files
87
COPY src/ui/frontend/package*.json ./
98

10-
# Install dependencies
119
RUN npm install
1210

13-
# Copy frontend source
1411
COPY src/ui/frontend/ ./
1512

16-
# Build the React app
1713
RUN npm run build
1814

1915
# Stage 2: Python runtime with FastAPI
2016
FROM python:3.9-slim
2117

2218
WORKDIR /app
2319

24-
# Install system dependencies
2520
RUN apt-get update && apt-get install -y \
2621
&& rm -rf /var/lib/apt/lists/*
2722

28-
# Copy Python requirements
2923
COPY src/ui/requirements.txt ./
3024

31-
# Install Python dependencies
3225
RUN pip install --no-cache-dir -r requirements.txt
3326

34-
# Copy backend application code
3527
COPY src/ui/app/ ./app/
3628

37-
# Copy model checkpoint
38-
COPY src/ui/models/ ./models/
39-
40-
# Copy built frontend from stage 1
4129
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
4230

4331
# Create non-root user for security (HF Spaces requirement)
@@ -48,9 +36,7 @@ USER user
4836
# Expose port 7860 (Hugging Face Spaces default)
4937
EXPOSE 7860
5038

51-
# Set environment variables
5239
ENV PYTHONUNBUFFERED=1
5340
ENV PORT=7860
5441

55-
# Run the FastAPI application
5642
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]

src/ui/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Python dependencies for XRD Analysis Tool backend
21
fastapi==0.104.1
32
uvicorn[standard]==0.24.0
43
python-multipart==0.0.6

0 commit comments

Comments
 (0)