Skip to content

Commit 88aad1e

Browse files
committed
update docker image
1 parent 687b044 commit 88aad1e

File tree

4 files changed

+68
-57
lines changed

4 files changed

+68
-57
lines changed

.dockerignore

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
.idea/
2-
.DS_Store
1+
.git
2+
.gitmodules
33
*.pyc
4-
*.pclprof
5-
*.png
4+
*.pyo
5+
*.pyd
6+
__pycache__
7+
.DS_Store
68
node_modules
7-
pytc/
8-
logs/
9-
data/
10-
outputs/
11-
build/
9+
client/node_modules
10+
logs
11+
outputs
1212
.venv
13-
__pycache__
14-
.pytest_cache
13+
.env

Dockerfile

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,34 @@
1-
#centOS
2-
FROM nvidia/cuda:11.1.1-devel-ubi8
1+
FROM python:3.11-slim
32

4-
# Enable AppStream and install Python 3.9 and git
5-
RUN yum -y module enable python39 && \
6-
yum install -y python39-3.9.2 && \
7-
yum install -y python39-devel-3.9.2 && \
8-
yum install -y git && \
9-
yum clean all && \
10-
(python3.9 --version || echo "Python installation failed" && exit 1)
3+
ENV PYTHONDONTWRITEBYTECODE=1 \
4+
PYTHONUNBUFFERED=1 \
5+
UV_PROJECT_ENV=/app/.venv
116

12-
# Create a symbolic link to bind python to python3.9
13-
RUN ln -s /usr/bin/python3.9 /usr/bin/python
7+
RUN apt-get update && apt-get install -y --no-install-recommends \
8+
build-essential \
9+
curl \
10+
git \
11+
&& rm -rf /var/lib/apt/lists/*
1412

15-
# Install pip (if not already included)
16-
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
17-
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python
13+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh -s -- --install-dir /usr/local/bin
1814

19-
# Set working directory
2015
WORKDIR /app
2116

22-
# Install dependencies
23-
RUN pip3 install --no-cache-dir torch==1.9.0 torchvision==0.10.0 cuda-python==11.1.1
17+
COPY pyproject.toml uv.lock ./
18+
RUN uv sync --frozen --no-dev --python 3.11
2419

25-
# Download pytorch_connectomics at specific commit (version 1.0)
26-
RUN git clone https://github.com/zudi-lin/pytorch_connectomics.git /app/pytorch_connectomics && \
27-
cd /app/pytorch_connectomics && \
28-
git checkout 20ccfde
20+
COPY setup_pytorch_connectomics.sh ./setup_pytorch_connectomics.sh
21+
RUN chmod +x setup_pytorch_connectomics.sh && \
22+
./setup_pytorch_connectomics.sh --force && \
23+
uv pip install --directory /app --editable /app/pytorch_connectomics && \
24+
rm -rf /app/pytorch_connectomics/.git
2925

30-
COPY ./samples_pytc /app/samples_pytc
31-
COPY ./server_pytc /app/server_pytc
32-
COPY ./server_api /app/server_api
26+
COPY server_api ./server_api
27+
COPY server_pytc ./server_pytc
28+
COPY scripts/docker-entrypoint.sh ./scripts/docker-entrypoint.sh
3329

34-
WORKDIR /app/pytorch_connectomics
35-
RUN yum install -y libglvnd-glx-1.3.2 && \
36-
yum clean all && \
37-
pip3 install --no-cache-dir --editable .
30+
RUN chmod +x scripts/docker-entrypoint.sh
3831

39-
WORKDIR /app/server_api
40-
RUN pip3 install --no-cache-dir -r requirements.txt
41-
42-
WORKDIR /app
43-
# Copies the startup scripts, and runs it at CMD
44-
COPY ./start.sh /app/
45-
COPY ./setup_pytorch_connectomics.sh /app/
46-
RUN chmod +x start.sh setup_pytorch_connectomics.sh
47-
48-
# Expose ports
4932
EXPOSE 4242 4243 4244 6006
50-
CMD [ "./start.sh"]
33+
34+
CMD ["./scripts/docker-entrypoint.sh"]

docker-compose.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
---
2-
version: '3.8'
1+
version: "3.9"
32

43
services:
5-
pytc-api:
6-
build: .
4+
backend:
5+
build:
6+
context: .
77
ports:
88
- "4242:4242"
99
- "4243:4243"
1010
- "4244:4244"
11-
volumes:
12-
- .:/app
13-
command: ./start.sh
11+
- "6006:6006"
12+
restart: unless-stopped

scripts/docker-entrypoint.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
API_PID=""
6+
PYTC_PID=""
7+
8+
cleanup() {
9+
local exit_code=$?
10+
for pid in "${API_PID}" "${PYTC_PID}"; do
11+
if [[ -n "${pid}" ]] && kill -0 "${pid}" 2>/dev/null; then
12+
kill "${pid}" 2>/dev/null || true
13+
fi
14+
done
15+
wait || true
16+
exit "${exit_code}"
17+
}
18+
19+
trap cleanup EXIT INT TERM
20+
21+
echo "Starting API server on :4242..."
22+
uv run --directory /app python server_api/main.py &
23+
API_PID=$!
24+
25+
echo "Starting PyTC server on :4243..."
26+
uv run --directory /app python server_pytc/main.py &
27+
PYTC_PID=$!
28+
29+
wait -n

0 commit comments

Comments
 (0)