-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
132 lines (99 loc) · 3.52 KB
/
Dockerfile
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
FROM nvidia/cuda:11.0.3-runtime-ubuntu18.04
#################################
## update/ install global dependencies
#################################
RUN apt-get update -y && \
apt-get upgrade -y
#################################
## create user
#################################
ARG USERNAME="efsfkk"
ARG CONDA_ENV="condaefs"
# Create user folders
RUN mkdir -p /home/${USERNAME} && mkdir -p /home/${USERNAME}/videos
# Create a non-root user
ARG uid=1000
ARG gid=100
ENV USER ${USERNAME}
ENV UID 1000
ENV GID 100
ENV HOME /home/${USERNAME}
RUN adduser --disabled-password \
--gecos "Non-root user" \
--uid ${UID} \
--gid ${GID} \
--home ${HOME} \
${USER}
RUN chown -R ${UID}:${GID} ${HOME}
#################################
## Basic installation
#################################
# This environment variable is nessecary for the apt-installation
ENV DEBIAN_FRONTEND noninteractive
# installation dependencies for miniconda, python and detectron2
RUN apt-get update && \
apt-get install -y \
wget \
python3-pip \
git \
python3-opencv \
ca-certificates \
python3-dev \
sudo \
ninja-build \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /home/${USERNAME}
#################################
## install miniconda
#################################
ENV CONDA_DIR /home/${USERNAME}/miniconda3
ENV ENV_PREFIX ${CONDA_DIR}/env
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \
/bin/bash ~/miniconda.sh -b -p ${CONDA_DIR} && \
rm -v ~/miniconda.sh
ENV PATH=${CONDA_DIR}/bin:${PATH}
RUN chown -R ${UID}:${GID} ${CONDA_DIR}
RUN chown -R ${UID}:${GID} /home/${USERNAME}/.conda
# Change User
USER ${USERNAME}
WORKDIR /home/${USERNAME}
# Install dependencies
COPY environment.yml ./environment.yml
RUN conda update --name base --channel defaults conda && \
conda install python=3.8 && \
conda env create --file environment.yml --name ${CONDA_ENV} --force && \
conda clean --all --yes
# activate conda environment for bash shell
RUN echo ". ${CONDA_DIR}/etc/profile.d/conda.sh" >> /home/${USERNAME}/.profile
RUN conda init bash
#################################
## install detectron2
#################################
ENV PATH="/home/$USERNAME/.local/bin:${PATH}"
## See https://pytorch.org/ for other options if you use a different version of CUDA
RUN python -m pip install torch==1.7.1 torchvision==0.8.2
#RUN python -m pip install --user 'git+https://github.com/facebookresearch/detectron2.git'
RUN python -m pip install --user detectron2 -f \
https://dl.fbaipublicfiles.com/detectron2/wheels/cu110/torch1.7/index.html
# https://dl.fbaipublicfiles.com/detectron2/wheels/cu111/torch1.10/index.html
#################################
## Install dependencies
#################################
RUN conda init bash && \
pip install cv2module pandas shapely scipy imantics sklearn
### Upload File - Dependencies ####
RUN pip install azure-storage-blob
#################################
## copy trafficmonitoring -repo
#################################
USER ${USERNAME}
COPY ./ ./trafficmonitoring
########################do#########
## create Entrypoint
################################
WORKDIR /home/${USERNAME}/trafficmonitoring/traffic_monitoring
USER root
#@TODO give user {USERNAME} permission on the directory where we get the video mounted
ENTRYPOINT [ "python", "run_on_video.py", "--video"]
#CMD ["/mnt/trafficmonitoring/small_example_video.mp4"]
#ENTRYPOINT [ "python", "run_on_video.py", "--video", "./videos/small_example_video.mp4" ]