Skip to content

Commit def9a47

Browse files
committed
add docker
1 parent 1812d5c commit def9a47

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Dockerfile for element-deeplabcut client environment
2+
# Uses DeepLabCut's official Docker image as base
3+
FROM deeplabcut/deeplabcut:latest-jupyter
4+
5+
# Set working directory
6+
WORKDIR /app
7+
8+
# Install additional system dependencies if needed
9+
RUN apt-get update && apt-get install -y \
10+
git \
11+
graphviz \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
# Copy the entire project
15+
COPY . .
16+
17+
# Install element-deeplabcut and its dependencies
18+
# The DLC image already has DeepLabCut installed, so we just need element-deeplabcut
19+
RUN pip install -e .[dlc_default,elements,tests]
20+
21+
# Set environment variables
22+
ENV PYTHONUNBUFFERED=1
23+
24+
# Set entrypoint to bash
25+
ENTRYPOINT ["/bin/bash"]
26+
27+
# Default command - interactive bash shell
28+
# Users can override with: docker compose run client -c "python your_script.py"
29+
CMD ["-i"]
30+

docker-compose.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Docker Compose configuration for element-deeplabcut client environment
2+
# Usage: docker compose up --build
3+
# docker compose run client python your_script.py
4+
5+
version: "3.8"
6+
7+
services:
8+
# MySQL database service
9+
db:
10+
restart: always
11+
image: datajoint/mysql:${MYSQL_VER:-8.0}
12+
environment:
13+
- MYSQL_ROOT_PASSWORD=${DJ_PASS:-datajoint}
14+
ports:
15+
- "${DB_PORT:-3306}:3306"
16+
volumes:
17+
- db_data:/var/lib/mysql
18+
healthcheck:
19+
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${DJ_PASS:-datajoint}"]
20+
timeout: 15s
21+
retries: 10
22+
interval: 15s
23+
networks:
24+
- element_network
25+
26+
# Client container
27+
client:
28+
build:
29+
context: .
30+
dockerfile: Dockerfile
31+
depends_on:
32+
db:
33+
condition: service_healthy
34+
environment:
35+
- DJ_HOST=db
36+
- DJ_USER=root
37+
- DJ_PASS=${DJ_PASS:-datajoint}
38+
- DJ_PORT=3306
39+
- DATABASE_PREFIX=${DATABASE_PREFIX:-}
40+
- DLC_ROOT_DATA_DIR=${DLC_ROOT_DATA_DIR:-/app/test_videos}
41+
- PYTHONUNBUFFERED=1
42+
volumes:
43+
# Mount data directory (can be customized via DLC_DATA_DIR env var)
44+
# Default: ./test_videos (for tests) or ./data (for general use)
45+
- ${DLC_DATA_DIR:-./test_videos}:/app/data
46+
# Mount config file if it exists
47+
- ./dj_local_conf.json:/app/dj_local_conf.json:ro
48+
# Mount the project directory for development
49+
- .:/app
50+
networks:
51+
- element_network
52+
# Default command - interactive bash (entrypoint is /bin/bash)
53+
# Example: docker compose run client -c "python test_trained_inference.py"
54+
command: ["-i"]
55+
stdin_open: true
56+
tty: true
57+
58+
volumes:
59+
db_data:
60+
61+
networks:
62+
element_network:
63+
driver: bridge
64+

docker-entrypoint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
# Docker entrypoint script for element-deeplabcut client
3+
# Works with DeepLabCut Docker image which already has DLC installed
4+
5+
set -e
6+
7+
# Execute the command
8+
exec "$@"
9+
10+

0 commit comments

Comments
 (0)