-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.web
More file actions
61 lines (49 loc) · 1.71 KB
/
Dockerfile.web
File metadata and controls
61 lines (49 loc) · 1.71 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
# eCan.ai Web Server Dockerfile
#
# This Dockerfile builds a headless web server image without Qt dependencies.
# It's optimized for multi-user web deployment.
#
# Build:
# docker build -f Dockerfile.web -t ecan-web .
#
# Run:
# docker run -p 8765:8765 -e ECAN_WS_PORT=8765 ecan-web
#
# With environment file:
# docker run -p 8765:8765 --env-file .env.web ecan-web
FROM python:3.12-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
ECAN_MODE=web \
ECAN_WS_HOST=0.0.0.0 \
ECAN_WS_PORT=8765
# Set working directory
WORKDIR /app
# Install system dependencies (minimal for headless)
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
libffi-dev \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user for security
RUN useradd --create-home --shell /bin/bash ecan
RUN chown -R ecan:ecan /app
# Copy requirements first for better caching
COPY requirements-base.txt ./
# Install Python dependencies (excluding Qt)
# Filter out PySide6 and other desktop-only dependencies
RUN pip install --no-cache-dir --upgrade pip && \
grep -v -E "^(PySide6|PyQt|qtpy)" requirements-base.txt > requirements-web.txt && \
pip install --no-cache-dir -r requirements-web.txt && \
pip install --no-cache-dir fastapi uvicorn websockets
# Copy application code
COPY --chown=ecan:ecan . .
# Switch to non-root user
USER ecan
# Expose WebSocket port
EXPOSE 8765
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8765/health')" || exit 1
# Default command
CMD ["python", "-m", "uvicorn", "web_server:app", "--host", "0.0.0.0", "--port", "8765"]