-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile.dev
More file actions
142 lines (120 loc) · 3.63 KB
/
Dockerfile.dev
File metadata and controls
142 lines (120 loc) · 3.63 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# Development Dockerfile with debugging and hot-reload support
# Based on development patterns from protein design tools
ARG PYTHON_VERSION=3.11
FROM python:${PYTHON_VERSION}-slim-bookworm AS dev-base
# Set environment variables for development
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
DEBIAN_FRONTEND=noninteractive \
DEVELOPMENT=1 \
LOG_LEVEL=DEBUG
# Install system dependencies for development
RUN apt-get update && apt-get install -y \
build-essential \
git \
curl \
wget \
ca-certificates \
gnupg2 \
software-properties-common \
vim \
nano \
tree \
htop \
procps \
strace \
gdb \
valgrind \
net-tools \
iputils-ping \
telnet \
hwloc \
libhwloc-dev \
mesa-opencl-icd \
ocl-icd-opencl-dev \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user with sudo access
RUN groupadd -r appuser && \
useradd -r -g appuser -m -s /bin/bash appuser && \
mkdir -p /app && \
chown appuser:appuser /app
# Install Node.js for frontend development (if needed)
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
apt-get install -y nodejs
WORKDIR /app
# Install Python development tools
RUN pip install --upgrade pip setuptools wheel
# Install core development dependencies
RUN pip install \
debugpy \
ipython \
jupyter \
notebook \
jupyterlab \
black \
isort \
flake8 \
mypy \
pylint \
bandit \
safety \
pre-commit \
pytest \
pytest-cov \
pytest-xdist \
pytest-mock \
pytest-benchmark \
pytest-timeout \
hypothesis \
factory-boy \
freezegun \
responses \
httpx \
watchdog
# Copy requirements files
COPY requirements*.txt ./
# Install project dependencies
RUN pip install -r requirements.txt || true
RUN pip install -r requirements-dev.txt || true
RUN pip install -r requirements-test.txt || true
# Copy source code
COPY --chown=appuser:appuser . .
# Install package in editable mode
RUN pip install -e ".[dev,test]" || pip install -e .
# Create development directories
RUN mkdir -p \
/app/data \
/app/logs \
/app/config \
/app/notebooks \
/app/scripts \
/app/tmp \
&& chown -R appuser:appuser /app
# Set up git configuration
RUN git config --global --add safe.directory /app
# Install pre-commit hooks
RUN pre-commit install --install-hooks || true
# Switch to non-root user
USER appuser
# Create useful aliases and environment
RUN echo 'alias ll="ls -la"' >> ~/.bashrc && \
echo 'alias la="ls -la"' >> ~/.bashrc && \
echo 'alias ..="cd .."' >> ~/.bashrc && \
echo 'alias pytest="python -m pytest"' >> ~/.bashrc && \
echo 'alias ipython="python -m IPython"' >> ~/.bashrc && \
echo 'export PYTHONPATH=/app:$PYTHONPATH' >> ~/.bashrc
# Set up Jupyter configuration
RUN jupyter notebook --generate-config && \
echo "c.NotebookApp.ip = '0.0.0.0'" >> ~/.jupyter/jupyter_notebook_config.py && \
echo "c.NotebookApp.port = 8888" >> ~/.jupyter/jupyter_notebook_config.py && \
echo "c.NotebookApp.open_browser = False" >> ~/.jupyter/jupyter_notebook_config.py && \
echo "c.NotebookApp.allow_root = True" >> ~/.jupyter/jupyter_notebook_config.py
# Health check for development
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD python -c "import ipfs_kit_py; print('Development environment OK')" || exit 1
# Expose ports for development services
EXPOSE 8000 5678 8888 8080
# Default command for development
CMD ["python", "-m", "debugpy", "--listen", "0.0.0.0:5678", "--wait-for-client", "-m", "ipfs_kit_py"]