-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (57 loc) · 2.48 KB
/
Dockerfile
File metadata and controls
75 lines (57 loc) · 2.48 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Multi-stage build for smaller final image
FROM python:3.11-slim AS builder
# Set build environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Create and use non-root user
RUN groupadd --gid 1001 symbiont && \
useradd --uid 1001 --gid symbiont --shell /bin/bash --create-home symbiont
# Set working directory
WORKDIR /app
# Copy requirements and install dependencies
COPY requirements.txt requirements-dev.txt ./
RUN pip install --user --no-cache-dir -r requirements.txt
# Copy source code
COPY . .
# Install the package
RUN pip install --user .
# Production stage
FROM python:3.11-slim
# Set runtime environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PATH="/home/symbiont/.local/bin:$PATH"
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd --gid 1001 symbiont && \
useradd --uid 1001 --gid symbiont --shell /bin/bash --create-home symbiont
# Copy installed packages from builder
COPY --from=builder --chown=symbiont:symbiont /root/.local /home/symbiont/.local
# Copy source code
WORKDIR /app
COPY --chown=symbiont:symbiont . .
# Switch to non-root user
USER symbiont
# Verify installation
RUN python -c "import symbiont; print(f'Symbiont SDK v{symbiont.__version__} installed successfully')"
# Default command - Python REPL with SDK available
CMD ["python", "-c", "import symbiont; print('Symbiont SDK ready. Use: from symbiont import SymbiontClient'); exec(open('/dev/stdin').read()) if not __import__('sys').stdin.isatty() else __import__('code').interact(local=globals())"]
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import symbiont; print('OK')" || exit 1
# Labels for metadata
LABEL org.opencontainers.image.title="Symbiont Python SDK" \
org.opencontainers.image.description="Python SDK for Symbiont platform with Tool Review and Runtime APIs" \
org.opencontainers.image.url="https://github.com/thirdkeyai/symbiont-sdk-python" \
org.opencontainers.image.source="https://github.com/thirdkeyai/symbiont-sdk-python" \
org.opencontainers.image.vendor="ThirdKey.ai" \
org.opencontainers.image.licenses="MIT"