-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
106 lines (78 loc) · 3.1 KB
/
Copy pathDockerfile
File metadata and controls
106 lines (78 loc) · 3.1 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# BooFun Docker Image
# Multi-stage build for optimized production image
# ============================================================================
# Stage 1: Builder
# ============================================================================
FROM python:3.11-slim@sha256:89abad2fb0c3633705054018ae09caae4bd0e0febf57fb57a96fd41769c94e12 AS builder
WORKDIR /build
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Create virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Install Python dependencies
COPY pyproject.toml setup.cfg ./
COPY src/ ./src/
# Install package with all optional dependencies
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install --no-cache-dir ".[performance,visualization]"
# ============================================================================
# Stage 2: Production Image
# ============================================================================
FROM python:3.11-slim@sha256:89abad2fb0c3633705054018ae09caae4bd0e0febf57fb57a96fd41769c94e12 AS production
LABEL maintainer="Gabriel Taboada <gabtab@berkeley.edu>"
LABEL description="BooFun: Boolean Function Analysis Library"
LABEL version="1.2.0"
WORKDIR /app
# Copy virtual environment from builder
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Copy source code
COPY src/ ./src/
COPY notebooks/ ./notebooks/
COPY docs/ ./docs/
COPY pyproject.toml setup.cfg ./
# Create non-root user
RUN useradd --create-home --shell /bin/bash boofun && \
chown -R boofun:boofun /app
USER boofun
# Expose Jupyter port
EXPOSE 8888
# Default command: start Jupyter
CMD ["jupyter", "notebook", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--notebook-dir=/app/notebooks"]
# ============================================================================
# Stage 3: Development Image
# ============================================================================
FROM python:3.11@sha256:387dc0304019d0c6e347b816377886a15a311c6a42c336ccdf262d3fa2fdbaca AS development
LABEL description="BooFun Development Environment"
WORKDIR /workspace
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
git \
vim \
&& rm -rf /var/lib/apt/lists/*
# Create virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Install all dependencies including dev
COPY pyproject.toml setup.cfg ./
COPY src/ ./src/
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install --no-cache-dir -e ".[all]"
# Copy everything
COPY . .
# Expose ports for Jupyter and docs
EXPOSE 8888 8000
CMD ["/bin/bash"]
# ============================================================================
# Stage 4: Notebook Runner
# ============================================================================
FROM production AS notebook
# Install Jupyter
RUN pip install --no-cache-dir jupyter jupyterlab
CMD ["jupyter", "lab", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--notebook-dir=/app/notebooks"]