Spaces:
Building
Building
Update Dockerfile
Browse files- Dockerfile +48 -8
Dockerfile
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
FROM python:3.8
|
2 |
|
3 |
# Create a non-root user
|
@@ -7,26 +9,64 @@ WORKDIR /home/user
|
|
7 |
|
8 |
ENV PATH="/home/user/.local/bin:$PATH"
|
9 |
|
10 |
-
# Install system packages needed for OpenCV
|
11 |
USER root
|
12 |
RUN apt-get update && \
|
13 |
-
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
&& rm -rf /var/lib/apt/lists/*
|
16 |
USER user
|
17 |
|
18 |
-
# Copy your code
|
19 |
-
COPY --chown=user . .
|
20 |
-
|
21 |
# Install Python dependencies
|
22 |
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
RUN pip install --no-cache-dir -e .
|
24 |
|
25 |
-
#
|
26 |
RUN mkdir -p /home/user/torchserve/model-store
|
27 |
RUN wget https://github.com/facebookresearch/AnimatedDrawings/releases/download/v0.0.1/drawn_humanoid_detector.mar -P /home/user/torchserve/model-store/
|
28 |
RUN wget https://github.com/facebookresearch/AnimatedDrawings/releases/download/v0.0.1/drawn_humanoid_pose_estimator.mar -P /home/user/torchserve/model-store/
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
EXPOSE 7860 8080 8081 8082
|
31 |
|
32 |
-
|
|
|
|
1 |
+
# syntax = docker/dockerfile:1.2
|
2 |
+
|
3 |
FROM python:3.8
|
4 |
|
5 |
# Create a non-root user
|
|
|
9 |
|
10 |
ENV PATH="/home/user/.local/bin:$PATH"
|
11 |
|
12 |
+
# Install system packages needed for OpenCV and other dependencies
|
13 |
USER root
|
14 |
RUN apt-get update && \
|
15 |
+
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
|
16 |
+
ca-certificates \
|
17 |
+
curl \
|
18 |
+
vim \
|
19 |
+
sudo \
|
20 |
+
default-jre \
|
21 |
+
git \
|
22 |
+
gcc \
|
23 |
+
build-essential \
|
24 |
+
libgl1-mesa-glx \
|
25 |
+
libglib2.0-0 \
|
26 |
+
netcat \
|
27 |
&& rm -rf /var/lib/apt/lists/*
|
28 |
USER user
|
29 |
|
|
|
|
|
|
|
30 |
# Install Python dependencies
|
31 |
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
|
32 |
+
RUN pip install --no-cache-dir openmim
|
33 |
+
RUN pip install --no-cache-dir torch==2.0.0
|
34 |
+
RUN mim install mmcv-full==1.7.0
|
35 |
+
RUN pip install --no-cache-dir mmdet==2.27.0
|
36 |
+
RUN pip install --no-cache-dir torchserve
|
37 |
+
|
38 |
+
# Clone and install xtcocoapi (a dependency for mmpose)
|
39 |
+
RUN git clone https://github.com/jin-s13/xtcocoapi.git
|
40 |
+
WORKDIR xtcocoapi
|
41 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
42 |
+
RUN python setup.py install
|
43 |
+
WORKDIR /home/user
|
44 |
+
|
45 |
+
# Install additional Python packages
|
46 |
+
RUN pip install --no-cache-dir mmpose==0.29.0
|
47 |
+
RUN pip install --no-cache-dir torchvision==0.15.1 numpy==1.24.4
|
48 |
+
|
49 |
+
# Copy your application code
|
50 |
+
COPY --chown=user . .
|
51 |
+
|
52 |
+
# Install your application's Python dependencies
|
53 |
RUN pip install --no-cache-dir -e .
|
54 |
|
55 |
+
# Prepare TorchServe model-store and download necessary models
|
56 |
RUN mkdir -p /home/user/torchserve/model-store
|
57 |
RUN wget https://github.com/facebookresearch/AnimatedDrawings/releases/download/v0.0.1/drawn_humanoid_detector.mar -P /home/user/torchserve/model-store/
|
58 |
RUN wget https://github.com/facebookresearch/AnimatedDrawings/releases/download/v0.0.1/drawn_humanoid_pose_estimator.mar -P /home/user/torchserve/model-store/
|
59 |
|
60 |
+
# Copy TorchServe configuration
|
61 |
+
COPY config.properties /home/user/torchserve/config.properties
|
62 |
+
COPY config.local.properties /home/user/torchserve/config.local.properties # If needed
|
63 |
+
|
64 |
+
# Copy the start.sh script
|
65 |
+
COPY start.sh /home/user/start.sh
|
66 |
+
RUN chmod +x /home/user/start.sh
|
67 |
+
|
68 |
+
# Expose necessary ports
|
69 |
EXPOSE 7860 8080 8081 8082
|
70 |
|
71 |
+
# Start both TorchServe and Gradio
|
72 |
+
CMD ["/home/user/start.sh"]
|