Skip to content

Commit 7da7bf2

Browse files
committed
extend theia-python-latest. docker
Signed-off-by: Chris Snow <[email protected]>
1 parent a7c6095 commit 7da7bf2

File tree

2 files changed

+58
-51
lines changed

2 files changed

+58
-51
lines changed

Dockerfile

Lines changed: 51 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,78 @@
1-
ARG NODE_VERSION=10
2-
FROM node:${NODE_VERSION}
1+
FROM theiaide/theia-python:latest
32

43
COPY requirements.txt /tmp
54

6-
USER root
7-
8-
# Python2 and Python3 are installed by parent Dockerfile:
9-
# https://github.com/theia-ide/theia-apps/blob/master/theia-full-docker/Dockerfile
10-
11-
# Save the preinstalled python paths - do this before setting up pyenv because pyenv may report
12-
# different binaries with which.
13-
14-
RUN which python > ~/python2_path
15-
RUN which python3 > ~/python3_path
5+
## User account
6+
RUN adduser --disabled-password --gecos '' theia && \
7+
adduser theia sudo && \
8+
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
9+
chown -R theia:theia /home/theia
1610

1711
RUN apt-get update \
18-
&& apt-get install -y vim yarn \
19-
&& apt-get install -y make build-essential libssl-dev zlib1g-dev \
12+
&& apt-get install -y vim yarn \
13+
&& apt-get install -y make build-essential libssl-dev zlib1g-dev \
2014
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
2115
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git \
2216
&& apt-get clean \
2317
&& apt-get auto-remove -y \
2418
&& rm -rf /var/cache/apt/* \
2519
&& rm -rf /var/lib/apt/lists/*
2620

27-
RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv \
21+
USER theia
22+
WORKDIR /home/theia
23+
24+
# Python2 and Python3 are installed by parent Dockerfile:
25+
# https://github.com/theia-ide/theia-apps/blob/master/theiaide/theia-python/Dockerfile
26+
27+
# Save the preinstalled python paths - do this before setting up pyenv because pyenv may report
28+
# different binaries with which.
29+
30+
RUN which python > ~/python2_path
31+
RUN which python3 > ~/python3_path
32+
33+
RUN /bin/bash -c " \
34+
git clone https://github.com/pyenv/pyenv.git ~/.pyenv \
2835
&& git clone https://github.com/momo-lab/xxenv-latest.git ~/.pyenv/plugins/latest \
29-
&& echo 'export PYENV_ROOT="~/.pyenv"' >> ~/.bashrc \
36+
"
37+
38+
RUN echo 'export PYENV_ROOT="~/.pyenv"' >> ~/.bashrc \
3039
&& echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc \
3140
&& echo 'if command -v pyenv 1>/dev/null 2>&1; then eval "$(pyenv init -)"; fi' >> ~/.bashrc
3241

33-
RUN /root/.pyenv/bin/pyenv latest install 2.7 \
34-
&& /root/.pyenv/bin/pyenv latest install 3.5 \
35-
&& /root/.pyenv/bin/pyenv latest install 3.6 \
36-
&& /root/.pyenv/bin/pyenv latest install 3.7 \
37-
&& /root/.pyenv/bin/pyenv latest install 3.8 \
38-
&& /root/.pyenv/bin/pyenv install 3.9-dev \
39-
&& /root/.pyenv/bin/pyenv local $(/root/.pyenv/bin/pyenv versions --bare) \
40-
&& /root/.pyenv/bin/pyenv versions
42+
RUN cat ~/.bashrc
43+
44+
RUN export PATH=/home/theia/.pyenv/bin:$PATH; \
45+
eval "$(/home/theia/.pyenv/bin/pyenv init -)"; \
46+
pyenv latest install 2.7 \
47+
&& pyenv latest install 3.5 \
48+
&& pyenv latest install 3.6 \
49+
&& pyenv latest install 3.7 \
50+
&& pyenv latest install 3.8 \
51+
&& pyenv install 3.9-dev \
52+
&& pyenv local $(pyenv versions --bare) \
53+
&& pyenv versions
4154

42-
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
43-
&& python get-pip.py
55+
# RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
56+
# && sudo python get-pip.py
57+
58+
USER root
4459

4560
RUN echo "Installing python modules" \
46-
&& PY_PATHS=$(ls -1 ~/.pyenv/versions/*/bin/python?.? && cat ~/python3_path && cat ~/python2_path) \
47-
&& PY_PATHS=$(cat ~/python3_path && cat ~/python2_path) \
61+
&& PY_PATHS=$(ls -1 /home/theia/.pyenv/versions/*/bin/python?.? && cat /home/theia/python3_path && cat /home/theia/python2_path) \
62+
&& PY_PATHS=$(cat /home/theia/python3_path && cat /home/theia/python2_path) \
4863
&& for v in ${PY_PATHS}; do ${v} -m pip install --upgrade pip setuptools wheel; done \
4964
&& for v in ${PY_PATHS}; do ${v} -m pip install --upgrade tox tox-pyenv ipython pylint pytest mock nose flake8 flake8-docstrings autopep8; done \
50-
&& ~/.pyenv/versions/*/bin/python3.8 -m pip install -U black isort python-language-server sphinx\
51-
&& ln -f -s ~/.pyenv/versions/*/bin/black /bin/ \
52-
&& ln -f -s ~/.pyenv/versions/*/bin/isort /bin/ \
65+
&& /home/theia/.pyenv/versions/*/bin/python3.8 -m pip install -U black isort python-language-server sphinx\
66+
&& ln -f -s /home/theia/.pyenv/versions/*/bin/black /bin/ \
67+
&& ln -f -s /home/theia/.pyenv/versions/*/bin/isort /bin/ \
5368
&& for v in ${PY_PATHS}; do ${v} -m pip install -r /tmp/requirements.txt; done
5469

70+
RUN chown -R theia:theia /home/theia
71+
72+
USER theia
73+
WORKDIR /home/theia
74+
5575
#RUN echo 'PATH=$PATH:/home/theia/.local/bin/' >> /home/theia/.bashrc
5676

5777
ENV PYTHONPATH=/home/project:$PYTHONPATH
5878

59-
RUN mkdir -p /home/theia \
60-
&& mkdir -p /home/project
61-
WORKDIR /home/theia
62-
63-
ARG version=latest
64-
ADD $version.package.json ./package.json
65-
ARG GITHUB_TOKEN
66-
RUN yarn --cache-folder ./ycache && rm -rf ./ycache && \
67-
NODE_OPTIONS="--max_old_space_size=4096" yarn theia build ; \
68-
yarn theia download:plugins
69-
EXPOSE 3000
70-
ENV SHELL=/bin/bash \
71-
THEIA_DEFAULT_PLUGINS=local-dir:/home/theia/plugins
72-
ENTRYPOINT [ "yarn", "theia", "start", "/home/project", "--hostname=0.0.0.0" ]

pre_push_verifications.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ flake8 --docstring-convention numpy bin/ hpecp/
1010

1111
flake8 --ignore=D,E501 tests/ # verify tests, but not for documentation
1212

13-
if [[ -d /home/theia/ ]];
14-
then
15-
# ensure pyenvs are available to tox
16-
eval "$(pyenv init -)"
17-
pyenv shell $(/root/.pyenv/bin/pyenv versions --bare)
18-
fi
13+
# if [[ -d /home/theia/ ]];
14+
# then
15+
# # ensure pyenvs are available to tox
16+
# eval "$(pyenv init -)"
17+
# ls -1 ~/.pyenv/versions/ > /root/.python-version
18+
# pyenv shell $(ls -1 ~/.pyenv/versions/)
19+
# fi
1920

2021
tox -- tests/
2122

0 commit comments

Comments
 (0)