-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
73 lines (52 loc) · 1.75 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
ARG CUDA_VERSION="11.7.1"
FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu22.04
SHELL ["/bin/bash", "-c"]
# set timezone
ARG TIMEZONE="Europe/Warsaw"
RUN set -Eeuxo pipefail && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
tzdata && \
echo "${TIMEZONE}" > /etc/timezone && \
cp "/usr/share/zoneinfo/${TIMEZONE}" /etc/localtime && \
apt-get -qy autoremove && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# add a non-root user
ARG USER_ID=1000
ARG GROUP_ID=1000
ARG AUX_GROUP_IDS=""
RUN set -Eeuxo pipefail && \
(addgroup --gid "${GROUP_ID}" user || echo "group ${GROUP_ID} already exists, so not adding it") && \
adduser --disabled-password --gecos "User" --uid "${USER_ID}" --gid "${GROUP_ID}" user && \
echo ${AUX_GROUP_IDS} | xargs -n1 echo | xargs -I% addgroup --gid % group% && \
echo ${AUX_GROUP_IDS} | xargs -n1 echo | xargs -I% usermod --append --groups group% user
# install dependencies
RUN set -Eeuxo pipefail && \
apt-get update && \
apt-get install --no-install-recommends -y \
git \
libudev1 \
python3-dev \
python3-numpy \
python3-pip \
python3-venv \
sudo && \
apt-get -qy autoremove && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
USER user
RUN set -Eeuxo pipefail && \
mkdir -p ~/system-query ~/.local/{bin,lib,share}
USER root
WORKDIR /home/user/system-query
COPY --chown=${USER_ID}:${GROUP_ID} requirements*.txt ./
RUN set -Eeuxo pipefail && \
pip3 install --no-cache-dir -r requirements_ci.txt
# add user to sudoers
RUN set -Eeuxo pipefail && \
usermod --append --groups sudo user && \
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# prepare system-query for testing
USER user
VOLUME ["/home/user/system-query"]