Skip to content

Commit 86f40ea

Browse files
committed
Improve dockerfile
Signed-off-by: Chris Snow <[email protected]>
1 parent 13c2971 commit 86f40ea

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

Dockerfile

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,22 @@ RUN adduser --disabled-password --gecos '' theia && \
2020
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
2121
chown -R theia:theia /home/theia
2222

23+
RUN echo "Installing python modules in system python versions" \
24+
&& PY_PATHS="/usr/bin/python /usr/bin/python3 and /usr/local/bin/python3" \
25+
&& for v in ${PY_PATHS}; do echo "******* ${v} *******"; ${v} -m pip install --upgrade pip setuptools wheel; done \
26+
&& for v in ${PY_PATHS}; do echo "******* ${v} *******"; ${v} -m pip install --upgrade tox tox-pyenv ipython pylint pytest mock nose flake8 flake8-docstrings autopep8; done \
27+
&& for v in ${PY_PATHS}; do ${v} -m pip install -r /tmp/requirements.txt; done \
28+
&& /usr/local/bin/python3 -m pip install -U black isort
29+
#&& ln -f -s /home/theia/.pyenv/versions/*/bin/black /bin/ \
30+
#&& ln -f -s /home/theia/.pyenv/versions/*/bin/isort /bin/
2331

2432
USER theia
2533
WORKDIR /home/theia
2634

27-
# Python2 and Python3 are installed by parent Dockerfile:
28-
# https://github.com/theia-ide/theia-apps/blob/master/theiaide/theia-python/Dockerfile
29-
# Here we save the preinstalled python paths because we need to use them later.
30-
31-
RUN which python > ~/python2_path
32-
RUN which python3 > ~/python3_path
33-
3435
RUN /bin/bash -c " \
3536
git clone https://github.com/pyenv/pyenv.git ~/.pyenv \
3637
&& git clone https://github.com/momo-lab/xxenv-latest.git ~/.pyenv/plugins/latest \
37-
"
38+
&& git clone https://github.com/doloopwhile/pyenv-register.git ~/.pyenv/plugins/pyenv-register"
3839

3940
RUN echo 'export PYENV_ROOT="/home/theia/.pyenv"' >> ~/.bashrc \
4041
&& echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc \
@@ -50,27 +51,19 @@ RUN export PATH=/home/theia/.pyenv/bin:$PATH; \
5051
&& pyenv latest install 3.7 \
5152
&& pyenv latest install 3.8 \
5253
&& pyenv install 3.9-dev \
54+
&& pyenv register /usr/bin/python \
55+
&& pyenv register /usr/bin/python3 \
56+
&& pyenv register /usr/local/bin/python3 \
5357
&& pyenv local $(pyenv versions --bare) \
5458
&& pyenv versions
5559

56-
RUN echo "Installing python modules" \
57-
&& PY_PATHS=$(ls -1 /home/theia/.pyenv/versions/*/bin/python?.?) \
60+
RUN echo "Installing python modules in pyenv python versions" \
61+
&& PY_PATHS=$(ls -1 /home/theia/.pyenv/versions/[0-9]*/bin/python?.?) \
5862
&& for v in ${PY_PATHS}; do echo "******* ${v} *******"; ${v} -m pip install --upgrade pip setuptools wheel; done \
5963
&& for v in ${PY_PATHS}; do echo "******* ${v} *******"; ${v} -m pip install --upgrade tox tox-pyenv ipython pylint pytest mock nose flake8 flake8-docstrings autopep8; done \
6064
&& for v in ${PY_PATHS}; do ${v} -m pip install -r /tmp/requirements.txt; done
6165

62-
USER root
6366

64-
RUN echo "Installing python modules" \
65-
&& PY_PATHS=$(cat /home/theia/python3_path && cat /home/theia/python2_path) \
66-
&& for v in ${PY_PATHS}; do echo "******* ${v} *******"; ${v} -m pip install --upgrade pip setuptools wheel; done \
67-
&& for v in ${PY_PATHS}; do echo "******* ${v} *******"; ${v} -m pip install --upgrade tox tox-pyenv ipython pylint pytest mock nose flake8 flake8-docstrings autopep8; done \
68-
&& for v in ${PY_PATHS}; do ${v} -m pip install -r /tmp/requirements.txt; done \
69-
&& /home/theia/.pyenv/versions/*/bin/python3.8 -m pip install -U black isort \
70-
&& ln -f -s /home/theia/.pyenv/versions/*/bin/black /bin/ \
71-
&& ln -f -s /home/theia/.pyenv/versions/*/bin/isort /bin/
72-
73-
USER theia
7467
WORKDIR /home/theia
7568

7669
ENV PYTHONPATH=/home/project:$PYTHONPATH

0 commit comments

Comments
 (0)