-
Notifications
You must be signed in to change notification settings - Fork 20
/
Dockerfile
59 lines (48 loc) · 1.61 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
FROM nvidia/cuda:10.0-base-ubuntu16.04
# Install some basic utilities
RUN apt-get update && apt-get install -y \
curl \
ca-certificates \
sudo \
git \
bzip2 \
libx11-6 \
&& rm -rf /var/lib/apt/lists/*
# Create a working directory
RUN mkdir /app
WORKDIR /app
# Create a non-root user and switch to it
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
&& chown -R user:user /app
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
USER user
# All users can use /home/user as their home directory
ENV HOME=/home/user
RUN chmod 777 /home/user
# Install Miniconda
ENV CONDA_AUTO_UPDATE_CONDA=false
ENV PATH=/home/user/miniconda/bin:$PATH
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-4.7.12.1-Linux-x86_64.sh \
&& chmod +x ~/miniconda.sh \
&& ~/miniconda.sh -b -p ~/miniconda \
&& rm ~/miniconda.sh
# Setup conda environment
COPY environment.yml .
RUN conda env update --name base
# Use tkinter as the default matplotlib backend
RUN mkdir -p $HOME/.config/matplotlib \
&& echo "backend : TkAgg" > $HOME/.config/matplotlib/matplotlibrc
# Install other dependencies from pip
COPY requirements.txt .
RUN pip install -r requirements.txt
# Replace Pillow with the faster Pillow-SIMD (optional)
RUN pip uninstall -y pillow \
&& sudo apt-get update && sudo apt-get install -y gcc libjpeg8-dev zlib1g-dev \
&& pip install pillow-simd==6.2.2post1 \
&& sudo apt-get remove -y gcc \
&& sudo apt-get autoremove -y \
&& sudo rm -rf /var/lib/apt/lists/*
COPY --chown=user:user . /app
RUN pip install -U .
# Set the default command to python3
CMD ["python3"]