-
Notifications
You must be signed in to change notification settings - Fork 78
/
Dockerfile
75 lines (65 loc) · 2.26 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
FROM ubuntu:20.04
USER root
WORKDIR /root
SHELL [ "/bin/bash", "-c" ]
ARG PYTHON_VERSION_TAG=3.10.5
ARG LINK_PYTHON_TO_PYTHON3=1
# Existing lsb_release causes issues with modern installations of Python3
# https://github.com/pypa/pip/issues/4924#issuecomment-435825490
# Set (temporarily) DEBIAN_FRONTEND to avoid interacting with tzdata
RUN apt-get -qq -y update && \
DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
gcc \
g++ \
zlibc \
zlib1g-dev \
libssl-dev \
libbz2-dev \
libsqlite3-dev \
libncurses5-dev \
libgdbm-dev \
libgdbm-compat-dev \
liblzma-dev \
libreadline-dev \
uuid-dev \
libffi-dev \
tk-dev \
wget \
curl \
git \
make \
sudo \
bash-completion \
tree \
vim \
software-properties-common && \
mv /usr/bin/lsb_release /usr/bin/lsb_release.bak && \
apt-get -y autoclean && \
apt-get -y autoremove && \
rm -rf /var/lib/apt/lists/*
COPY install_python.sh install_python.sh
RUN bash install_python.sh ${PYTHON_VERSION_TAG} ${LINK_PYTHON_TO_PYTHON3} && \
rm -r install_python.sh Python-${PYTHON_VERSION_TAG}
# Enable tab completion by uncommenting it from /etc/bash.bashrc
# The relevant lines are those below the phrase "enable bash completion in interactive shells"
RUN export SED_RANGE="$(($(sed -n '\|enable bash completion in interactive shells|=' /etc/bash.bashrc)+1)),$(($(sed -n '\|enable bash completion in interactive shells|=' /etc/bash.bashrc)+7))" && \
sed -i -e "${SED_RANGE}"' s/^#//' /etc/bash.bashrc && \
unset SED_RANGE
# Create user "docker" with sudo powers
RUN useradd -m docker && \
usermod -aG sudo docker && \
echo '%sudo ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers && \
cp /root/.bashrc /home/docker/ && \
mkdir /home/docker/data && \
chown -R --from=root docker /home/docker
# Use C.UTF-8 locale to avoid issues with ASCII encoding
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
WORKDIR /home/docker/data
ENV HOME /home/docker
ENV USER docker
USER docker
ENV PATH /home/docker/.local/bin:$PATH
# Avoid first use of sudo warning. c.f. https://askubuntu.com/a/22614/781671
RUN touch $HOME/.sudo_as_admin_successful
CMD [ "/bin/bash" ]