-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathDockerfile
142 lines (117 loc) · 4.53 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
131
132
133
134
135
136
137
138
139
140
141
142
# Anaconda3 / Miniconda3 Dockerfile
# Copyright (C) 2020-2023 Chelsea E. Manning
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
FROM ubuntu:jammy-20230624
LABEL description="Anaconda3 Vanilla Container"
# $ docker build --network=host -t xychelsea/anaconda3:latest -f Dockerfile .
# $ docker run --rm -it xychelsea/anaconda3:latest /bin/bash
# $ docker push xychelsea/anaconda3:latest
ARG ANACONDA_CONTAINER="v23.1.0"
ARG ANACONDA_DIST="Miniconda3"
ARG ANACONDA_PYTHON="py310"
ARG ANACONDA_CONDA="23.1.0"
ARG ANACONDA_OS="Linux"
ARG ANACONDA_ARCH="x86_64"
ARG ANACONDA_FLAVOR="Miniforge3"
ARG ANACONDA_PATCH="4"
ARG ANACONDA_VERSION="${ANACONDA_CONDA}-${ANACONDA_PATCH}"
ARG ANACONDA_INSTALLER="${ANACONDA_FLAVOR}-${ANACONDA_VERSION}-${ANACONDA_OS}-${ANACONDA_ARCH}.sh"
ARG ANACONDA_ENV="base"
ARG ANACONDA_GID="100"
ARG ANACONDA_PATH="/usr/local/anaconda3"
ARG ANACONDA_UID="1000"
ARG ANACONDA_USER="anaconda"
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
USER root
ENV DEBIAN_FRONTEND=noninteractive
# Update repository
RUN apt-get update --fix-missing
# Install dependencies
RUN apt-get install -y --no-install-recommends \
bzip2 \
ca-certificates \
curl \
locales \
sudo \
wget
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
&& locale-gen
# Configure environment
ENV ANACONDA_ENV=${ANACONDA_ENV} \
ANACONDA_PATH=${ANACONDA_PATH} \
ANACONDA_GID=${ANACONDA_GID} \
ANACONDA_UID=${ANACONDA_UID} \
ANACONDA_USER=${ANACONDA_USER} \
HOME=/home/${ANACONDA_USER} \
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
SHELL=/bin/bash
ENV PATH ${ANACONDA_PATH}/bin:${PATH}
# Enable prompt color, generally
RUN sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' /etc/skel/.bashrc
# Copy fix-permissions script
COPY scripts/fix-permissions /usr/local/bin/fix-permissions
# Create default user wtih name "anaconda"
RUN echo "auth requisite pam_deny.so" >> /etc/pam.d/su \
&& sed -i.bak -e 's/^%admin/#%admin/' /etc/sudoers \
&& sed -i.bak -e 's/^%sudo/#%sudo/' /etc/sudoers \
&& useradd -m -s /bin/bash -N -u ${ANACONDA_UID} ${ANACONDA_USER} \
&& mkdir -p ${ANACONDA_PATH} \
&& chown -R ${ANACONDA_USER}:${ANACONDA_GID} ${ANACONDA_PATH} \
&& chmod g+w /etc/passwd \
&& chmod a+rx /usr/local/bin/fix-permissions \
&& fix-permissions ${HOME} \
&& fix-permissions ${ANACONDA_PATH}
# Switch to user "anaconda"
USER ${ANACONDA_UID}
WORKDIR ${HOME}
# Install Anaconda (Miniconda) - https://anaconda.com/
RUN wget --verbose -O ~/${ANACONDA_VERSION}.sh https://github.com/conda-forge/miniforge/releases/download/${ANACONDA_VERSION}/${ANACONDA_INSTALLER} \
&& /bin/bash /home/${ANACONDA_USER}/${ANACONDA_VERSION}.sh -b -u -p ${ANACONDA_PATH} \
&& chown -R ${ANACONDA_USER} ${ANACONDA_PATH} \
&& rm -rvf ~/${ANACONDA_VERSION}.sh \
&& echo ". ${ANACONDA_PATH}/etc/profile.d/conda.sh" >> ~/.bashrc \
&& echo "conda activate \${ANACONDA_ENV}" >> ~/.bashrc \
&& find ${ANACONDA_PATH} -follow -type f -name '*.a' -delete \
&& find ${ANACONDA_PATH} -follow -type f -name '*.js.map' -delete \
&& fix-permissions ${HOME} \
&& fix-permissions ${ANACONDA_PATH}
# Update Anaconda
RUN conda update -c defaults conda
# Activate conda-forge
RUN conda config --add channels conda-forge
# Install Tini
RUN conda install -y tini
# Switch back to root
USER root
# Clean Anaconda
RUN conda clean -afy \
&& fix-permissions ${HOME} \
&& fix-permissions ${ANACONDA_PATH}
# Make configuration adjustments in /etc
RUN ln -s ${ANACONDA_PATH}/etc/profile.d/conda.sh /etc/profile.d/conda.sh \
&& fix-permissions /etc/profile.d/conda.sh
# Clean packages and caches
RUN apt-get --purge -y remove wget curl \
&& apt-get --purge -y autoremove \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* \
&& rm -rvf /home/${ANACONDA_PATH}/.cache/yarn
# Configure container startup
ENTRYPOINT [ "tini", "-g", "--" ]
CMD [ "/bin/bash" ]
# Re-activate user "anaconda"
USER $ANACONDA_UID
WORKDIR $HOME