File size: 2,173 Bytes
4607d95
f5f3936
bf103bf
f5f3936
bf103bf
 
 
b9fb924
bf103bf
f5f3936
bf103bf
 
4607d95
bf103bf
9820c02
bf103bf
602c04e
 
bf103bf
f5f3936
bf103bf
f5f3936
4607d95
9506fa0
7b813cc
f5f3936
 
 
4607d95
a24715a
3dfc91d
 
f5f3936
 
 
 
 
 
 
 
 
3dfc91d
4607d95
4b72e1d
f5f3936
f5951cd
 
 
f5f3936
4607d95
eb0aef1
9506fa0
4607d95
 
f5f3936
9506fa0
 
f5f3936
9506fa0
 
 
 
 
7b813cc
9506fa0
 
f5f3936
4607d95
 
 
d1c15a7
4607d95
7b813cc
4607d95
1647002
d86c7bd
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
# Stage 1: Base Python image
FROM python:3.9 as base

# Create a user and set environment variables
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
COPY --chown=user . $HOME/app

# Set working directory
WORKDIR /app

# Copy Python dependencies and install them
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir scikit-build
RUN pip install --no-cache-dir --upgrade -r requirements.txt
RUN pip install 'git+https://github.com/facebookresearch/detectron2.git'


# Copy application files
COPY --chown=user . /app

# Stage 2: CUDA and Detectron2
# FROM nvidia/cuda:11.1.1-cudnn8-devel-ubuntu18.04 as cuda

# Use noninteractive mode for apt-get
ENV DEBIAN_FRONTEND=noninteractive

# Install system dependencies
USER root
RUN apt-get update && apt-get clean
RUN apt-get update && apt-get install -y --fix-missing \
    python3-opencv \
    python3-pip \
    ca-certificates \
    python3-dev \
    git \
    wget \
    sudo \
    ninja-build


# Link Python and Pip commands
# RUN ln -sv /usr/bin/python3 /usr/bin/python && ln -sv /usr/bin/pip3 /usr/bin/pip

# # Copy dependencies from the base stage
# COPY --from=base /home/user/.local /home/user/.local
# COPY --from=base /app /app

# Install additional Python packages
RUN pip install --no-cache-dir scikit-build
# RUN pip install --no-cache-dir --upgrade -r requirements.txt
RUN pip install --no-cache-dir tensorboard cmake onnx
RUN pip install --no-cache-dir 'git+https://github.com/facebookresearch/fvcore'

# # Clone Detectron2 repository
# RUN git clone https://github.com/facebookresearch/detectron2 detectron2_repo

# # Set environment variables for Detectron2
# ENV FORCE_CUDA="1"
# ARG TORCH_CUDA_ARCH_LIST="Kepler;Kepler+Tesla;Maxwell;Maxwell+Tegra;Pascal;Volta;Turing"
# ENV TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST}"
# ENV FVCORE_CACHE="/tmp"

# # Install Detectron2 in editable mode
# RUN pip install --no-cache-dir -e detectron2_repo

# Set the working directory and environment
USER user
ENV HOME=/home/user
COPY --chown=user . $HOME/app
WORKDIR $HOME/app

# Expose application port and set default command
RUN ls -a
CMD ["python", "app.py"]