|
1 |
| -ARG NODE_VERSION=10 |
2 |
| -FROM node:${NODE_VERSION} |
| 1 | +FROM theiaide/theia-python:latest |
3 | 2 |
|
4 | 3 | COPY requirements.txt /tmp
|
5 | 4 |
|
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 |
16 | 10 |
|
17 | 11 | 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 \ |
20 | 14 | libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
|
21 | 15 | libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git \
|
22 | 16 | && apt-get clean \
|
23 | 17 | && apt-get auto-remove -y \
|
24 | 18 | && rm -rf /var/cache/apt/* \
|
25 | 19 | && rm -rf /var/lib/apt/lists/*
|
26 | 20 |
|
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 \ |
28 | 35 | && 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 \ |
30 | 39 | && echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc \
|
31 | 40 | && echo 'if command -v pyenv 1>/dev/null 2>&1; then eval "$(pyenv init -)"; fi' >> ~/.bashrc
|
32 | 41 |
|
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 |
41 | 54 |
|
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 |
44 | 59 |
|
45 | 60 | 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) \ |
48 | 63 | && for v in ${PY_PATHS}; do ${v} -m pip install --upgrade pip setuptools wheel; done \
|
49 | 64 | && 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/ \ |
53 | 68 | && for v in ${PY_PATHS}; do ${v} -m pip install -r /tmp/requirements.txt; done
|
54 | 69 |
|
| 70 | +RUN chown -R theia:theia /home/theia |
| 71 | + |
| 72 | +USER theia |
| 73 | +WORKDIR /home/theia |
| 74 | + |
55 | 75 | #RUN echo 'PATH=$PATH:/home/theia/.local/bin/' >> /home/theia/.bashrc
|
56 | 76 |
|
57 | 77 | ENV PYTHONPATH=/home/project:$PYTHONPATH
|
58 | 78 |
|
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" ] |
|
0 commit comments