amanmurari commited on
Commit
fe6e5bc
Β·
verified Β·
1 Parent(s): b6f80c5

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -15
Dockerfile CHANGED
@@ -3,15 +3,24 @@ FROM python:3.11-slim
3
  LABEL maintainer="OpenEnv Hackathon"
4
  LABEL description="Autonomous Traffic Control – OpenEnv Environment (self-contained)"
5
 
6
- WORKDIR /app
7
-
8
- # ── Install system deps ────────────────────────────────────────────────────
9
  RUN apt-get update && apt-get install -y --no-install-recommends \
10
  build-essential \
11
  && rm -rf /var/lib/apt/lists/*
12
 
 
 
 
 
 
 
 
 
13
  # ── Copy packaging manifest first (layer-cache friendly) ──────────────────
14
- COPY pyproject.toml README.md ./
 
 
 
15
 
16
  # ── Install Python deps ────────────────────────────────────────────────────
17
  RUN pip install --no-cache-dir \
@@ -27,14 +36,14 @@ RUN pip install --no-cache-dir \
27
  "python-multipart>=0.0.6"
28
 
29
  # ── Copy source (self-contained; no root-level deps needed) ───────────────
30
- COPY models.py ./traffic_control/models.py
31
- COPY environment.py ./traffic_control/environment.py
32
- COPY tasks.py ./traffic_control/tasks.py
33
- COPY client.py ./traffic_control/client.py
34
- COPY __init__.py ./traffic_control/__init__.py
35
- COPY inference.py ./traffic_control/inference.py
36
- COPY openenv.yaml ./traffic_control/openenv.yaml
37
- COPY server/ ./traffic_control/server/
38
 
39
  # ── Create package anchor so Python treats traffic_control/ as the package ─
40
  RUN echo "" > ./traffic_control/__init__.py || true
@@ -44,14 +53,14 @@ RUN pip install --no-cache-dir -e .
44
 
45
  # ── Runtime config ────────────────────────────────────────────────────────
46
  ENV WORKERS=2
47
- ENV PORT=8000
48
  ENV PYTHONDONTWRITEBYTECODE=1
49
  ENV PYTHONUNBUFFERED=1
50
 
51
- EXPOSE 8000
52
 
53
  HEALTHCHECK --interval=15s --timeout=5s --start-period=15s --retries=3 \
54
- CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"
55
 
56
  ENV ENABLE_WEB_INTERFACE=true
57
  CMD ["sh", "-c", \
 
3
  LABEL maintainer="OpenEnv Hackathon"
4
  LABEL description="Autonomous Traffic Control – OpenEnv Environment (self-contained)"
5
 
6
+ # ── Install system deps (as root) ──────────────────────────────────────────
 
 
7
  RUN apt-get update && apt-get install -y --no-install-recommends \
8
  build-essential \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
+ # ── Create user for Hugging Face Spaces (UID 1000) ─────────────────────────
12
+ RUN useradd -m -u 1000 user
13
+ USER user
14
+ ENV HOME=/home/user \
15
+ PATH=/home/user/.local/bin:$PATH
16
+
17
+ WORKDIR $HOME/app
18
+
19
  # ── Copy packaging manifest first (layer-cache friendly) ──────────────────
20
+ COPY --chown=user pyproject.toml README.md ./
21
+
22
+ # Fix the setuptools package lookup to not scan the root filesystem in Docker
23
+ RUN sed -i 's|where = \[".."\]|where = \["."\]|g' pyproject.toml || true
24
 
25
  # ── Install Python deps ────────────────────────────────────────────────────
26
  RUN pip install --no-cache-dir \
 
36
  "python-multipart>=0.0.6"
37
 
38
  # ── Copy source (self-contained; no root-level deps needed) ───────────────
39
+ COPY --chown=user models.py ./traffic_control/models.py
40
+ COPY --chown=user environment.py ./traffic_control/environment.py
41
+ COPY --chown=user tasks.py ./traffic_control/tasks.py
42
+ COPY --chown=user client.py ./traffic_control/client.py
43
+ COPY --chown=user __init__.py ./traffic_control/__init__.py
44
+ COPY --chown=user inference.py ./traffic_control/inference.py
45
+ COPY --chown=user openenv.yaml ./traffic_control/openenv.yaml
46
+ COPY --chown=user server/ ./traffic_control/server/
47
 
48
  # ── Create package anchor so Python treats traffic_control/ as the package ─
49
  RUN echo "" > ./traffic_control/__init__.py || true
 
53
 
54
  # ── Runtime config ────────────────────────────────────────────────────────
55
  ENV WORKERS=2
56
+ ENV PORT=7860
57
  ENV PYTHONDONTWRITEBYTECODE=1
58
  ENV PYTHONUNBUFFERED=1
59
 
60
+ EXPOSE 7860
61
 
62
  HEALTHCHECK --interval=15s --timeout=5s --start-period=15s --retries=3 \
63
+ CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')"
64
 
65
  ENV ENABLE_WEB_INTERFACE=true
66
  CMD ["sh", "-c", \