LapStore commited on
Commit
1083921
·
1 Parent(s): df2713b

uploaded backend files

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -50
Dockerfile CHANGED
@@ -1,55 +1,16 @@
1
- # syntax=docker/dockerfile:1
2
- FROM python:3.10-slim AS builder
3
 
4
- # Set environment variables
5
- ENV PYTHONDONTWRITEBYTECODE=1 \
6
- PYTHONUNBUFFERED=1 \
7
- PIP_NO_CACHE_DIR=1
8
 
9
- WORKDIR /app
 
 
10
 
11
- # Install system dependencies
12
- RUN apt-get update && apt-get install -y --no-install-recommends \
13
- build-essential \
14
- && rm -rf /var/lib/apt/lists/*
15
 
16
- # Create and activate virtual environment
17
- RUN python -m venv /opt/venv
18
- ENV PATH="/opt/venv/bin:$PATH"
19
 
20
- # Install Python dependencies
21
- COPY requirements.txt .
22
- RUN pip install --upgrade pip \
23
- && pip install --no-cache-dir -r requirements.txt
24
-
25
- # --- Runtime stage ---
26
- FROM python:3.10-slim
27
-
28
- # Platform-agnostic environment setup
29
- ENV PYTHONUNBUFFERED=1 \
30
- PATH="/opt/venv/bin:$PATH" \
31
- PORT=8000 \
32
- HOST=0.0.0.0
33
-
34
- WORKDIR /app
35
-
36
- # Copy virtual environment
37
- COPY --from=builder /opt/venv /opt/venv
38
-
39
- # Copy application code (with .dockerignore in place)
40
- COPY . .
41
-
42
- # Create non-root user and permissions
43
- RUN useradd -m appuser \
44
- && chown -R appuser:appuser /app \
45
- && mkdir -p /app/tmp \
46
- && chown appuser:appuser /app/tmp
47
-
48
- USER appuser
49
-
50
- # Health check (for platforms that support it)
51
- HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
52
- CMD curl -f http://localhost:$PORT/health || exit 1
53
-
54
- # Universal run command
55
- CMD ["sh", "-c", "uvicorn main:app --host $HOST --port $PORT"]
 
1
+ # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
 
4
+ FROM python:3.11
 
 
 
5
 
6
+ RUN useradd -m -u 1000 user
7
+ USER user
8
+ ENV PATH="/home/user/.local/bin:$PATH"
9
 
10
+ WORKDIR /main
 
 
 
11
 
12
+ COPY --chown=user ./requirements.txt requirements.txt
13
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
 
14
 
15
+ COPY --chown=user . /main
16
+ CMD ["uvicorn", "app:main", "--host", "0.0.0.0", "--port", "7860"]