Spaces:
Building
Building
Update Dockerfile
Browse files- Dockerfile +14 -29
Dockerfile
CHANGED
@@ -2,16 +2,14 @@
|
|
2 |
|
3 |
FROM python:3.8
|
4 |
|
5 |
-
#
|
6 |
RUN useradd -m -u 1000 user
|
7 |
-
|
8 |
-
# 2. Switch to the non-root user
|
9 |
USER user
|
10 |
WORKDIR /home/user
|
11 |
|
12 |
ENV PATH="/home/user/.local/bin:$PATH"
|
13 |
|
14 |
-
#
|
15 |
USER root
|
16 |
RUN apt-get update && \
|
17 |
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
|
@@ -25,13 +23,11 @@ RUN apt-get update && \
|
|
25 |
build-essential \
|
26 |
libgl1-mesa-glx \
|
27 |
libglib2.0-0 \
|
28 |
-
netcat \
|
29 |
&& rm -rf /var/lib/apt/lists/*
|
30 |
-
|
31 |
-
# 4. Switch back to the non-root user
|
32 |
USER user
|
33 |
|
34 |
-
#
|
35 |
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
|
36 |
RUN pip install --no-cache-dir openmim
|
37 |
RUN pip install --no-cache-dir torch==2.0.0
|
@@ -39,48 +35,37 @@ RUN mim install mmcv-full==1.7.0
|
|
39 |
RUN pip install --no-cache-dir mmdet==2.27.0
|
40 |
RUN pip install --no-cache-dir torchserve
|
41 |
|
42 |
-
#
|
43 |
RUN git clone https://github.com/jin-s13/xtcocoapi.git
|
44 |
WORKDIR xtcocoapi
|
45 |
RUN pip install --no-cache-dir -r requirements.txt
|
46 |
RUN pip install -e .
|
47 |
WORKDIR /home/user
|
48 |
|
49 |
-
#
|
50 |
RUN pip install --no-cache-dir mmpose==0.29.0
|
51 |
RUN pip install --no-cache-dir torchvision==0.15.1 numpy==1.24.4
|
52 |
|
53 |
-
#
|
54 |
COPY --chown=user . .
|
55 |
|
56 |
-
#
|
57 |
RUN pip install --no-cache-dir -e .
|
58 |
|
59 |
-
#
|
60 |
RUN mkdir -p /home/user/torchserve/model-store
|
61 |
RUN wget https://github.com/facebookresearch/AnimatedDrawings/releases/download/v0.0.1/drawn_humanoid_detector.mar -P /home/user/torchserve/model-store/
|
62 |
RUN wget https://github.com/facebookresearch/AnimatedDrawings/releases/download/v0.0.1/drawn_humanoid_pose_estimator.mar -P /home/user/torchserve/model-store/
|
63 |
|
64 |
-
#
|
65 |
-
USER root
|
66 |
-
|
67 |
-
# 12. Copy TorchServe configuration files
|
68 |
COPY config.properties /home/user/torchserve/config.properties
|
69 |
-
COPY config.local.properties /home/user/torchserve/config.local.properties
|
70 |
|
71 |
-
#
|
72 |
-
# Option A: Using --chmod flag (Recommended)
|
73 |
COPY --chmod=0755 start.sh /home/user/start.sh
|
74 |
|
75 |
-
#
|
76 |
-
# COPY start.sh /home/user/start.sh
|
77 |
-
# RUN chmod +x /home/user/start.sh
|
78 |
-
|
79 |
-
# 14. Switch back to the non-root user
|
80 |
-
USER user
|
81 |
-
|
82 |
-
# 15. Expose necessary ports
|
83 |
EXPOSE 7860 8080 8081 8082
|
84 |
|
85 |
-
#
|
86 |
CMD ["/home/user/start.sh"]
|
|
|
2 |
|
3 |
FROM python:3.8
|
4 |
|
5 |
+
# Create a non-root user
|
6 |
RUN useradd -m -u 1000 user
|
|
|
|
|
7 |
USER user
|
8 |
WORKDIR /home/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 \
|
|
|
23 |
build-essential \
|
24 |
libgl1-mesa-glx \
|
25 |
libglib2.0-0 \
|
26 |
+
netcat-openbsd \
|
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
|
|
|
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 pip install -e .
|
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 files
|
|
|
|
|
|
|
61 |
COPY config.properties /home/user/torchserve/config.properties
|
62 |
+
COPY config.local.properties /home/user/torchserve/config.local.properties # Ensure this file exists
|
63 |
|
64 |
+
# Copy the start.sh script and set executable permissions
|
|
|
65 |
COPY --chmod=0755 start.sh /home/user/start.sh
|
66 |
|
67 |
+
# Expose necessary ports
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
EXPOSE 7860 8080 8081 8082
|
69 |
|
70 |
+
# Start both TorchServe and Gradio
|
71 |
CMD ["/home/user/start.sh"]
|