Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

Use plugin with theia-docker? #8

Open
pwFoo opened this issue Jul 26, 2018 · 32 comments
Open

Use plugin with theia-docker? #8

pwFoo opened this issue Jul 26, 2018 · 32 comments

Comments

@pwFoo
Copy link

pwFoo commented Jul 26, 2018

I tested theia with docker (https://github.com/theia-ide/theia-apps#theia-docker) and would use the plugin / theia in a docker container.

Any instructions how to use theia-php-extension with the theia-docker image or how to extend the image to use it with the plugin?

@pwFoo
Copy link
Author

pwFoo commented Jul 27, 2018

I added "@theia/php": "0.0.0" (also added the needed comma in the line before) to package.json to "install" the module, but no php syntax highlighting if I open / create a php file? ".php" file is opened as type "Plain Text".

Added runtime and also inside of a volume before creating a new theia container.

So how to install / activate the plugin?

@pwFoo
Copy link
Author

pwFoo commented Aug 1, 2018

@meysholdt
Could You help me to install the plugin inside of theia docker container / image?

@meysholdt
Copy link
Collaborator

you'll need to make php available inside the docker image. There is probably some stuff you can copy from https://github.com/theia-ide/theia-php-extension/blob/master/Dockerfile.gitpod.

And composer is a compile-time dependency needed to install libraries required by the php language server. see:

# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
# https://linuxconfig.org/how-to-install-php-composer-on-debian-linux
RUN curl -s -o composer-setup.php https://getcomposer.org/installer \
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
&& rm composer-setup.php

@roynasser
Copy link

roynasser commented Aug 23, 2018

I'm also trying to get php working inside the docker editor...

Added composer to my dockerfile,

And added @theia/php to the packages file

But building the dockerfile gives me a bunch of warnings and craps out at:

[1/4] Resolving packages...
warning @theia/core > electron > electron-download > nugget > progress-stream > through2 > xtend > object-keys@0.4.0:
warning @theia/extension-manager > @theia/application-manager > less > request > hawk > hoek@2.16.3: The major version is no longer supported. Please update to 4.x or newer
warning @theia/extension-manager > @theia/application-manager > less > request > hawk > sntp > hoek@2.16.3: The major version is no longer supported. Please update to 4.x or newer
warning @theia/extension-manager > @theia/application-manager > less > request > hawk > boom > hoek@2.16.3: The major version is no longer supported. Please update to 4.x or newer
warning @theia/extension-manager > @theia/application-manager > css-loader > cssnano > autoprefixer > browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning @theia/extension-manager > @theia/application-manager > css-loader > cssnano > postcss-merge-rules > browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning @theia/extension-manager > @theia/application-manager > css-loader > cssnano > postcss-merge-rules > caniuse-api > browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning @theia/extension-manager > @theia/application-manager > webpack-cli > jscodeshift > nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
warning @theia/extension-manager > @theia/application-manager > webpack-cli > webpack-addons > jscodeshift > nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
warning @theia/extension-manager > @theia/application-manager > webpack-cli > jscodeshift > babel-preset-es2015@6.24.1: 🙌  Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
warning @theia/extension-manager > @theia/application-manager > webpack-cli > webpack-addons > jscodeshift > babel-preset-es2015@6.24.1: 🙌  Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
warning @theia/go > go-language-server > json-rpc2 > es5class@2.3.1: this package isn't maintained anymore because ES6+
[2/4] Fetching packages...
warning vscode-base-languageclient@0.0.1-alpha.5: The engine "vscode" appears to be invalid.
info fsevents@1.2.4: The platform "linux" is incompatible with this module.
info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
warning go-language-server@0.1.7: The engine "vscode" appears to be invalid.
warning vscode-extension-telemetry@0.0.10: The engine "vscode" appears to be invalid.
warning vscode-languageclient@2.6.3: The engine "vscode" appears to be invalid.
warning monaco-languageclient@0.8.0-next.3: The engine "vscode" appears to be invalid.
warning vscode-base-languageclient@4.4.0: The engine "vscode" appears to be invalid.
[3/4] Linking dependencies...
warning "@theia/extension-manager > @theia/application-manager > font-awesome-webpack@0.0.5-beta.2" has unmet peer dependency "font-awesome@>=4.3.0".
warning "theia-yang-extension > sprotty > snabbdom-virtualize@0.7.0" has incorrect peer dependency "snabbdom@~0.6.6".
[4/4] Building fresh packages...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error /home/theia/node_modules/@theia/php: Command failed.
Exit code: 1
Command: composer install
Arguments:
Directory: /home/theia/node_modules/@theia/php
Output:
Composer could not find a composer.json file in /home/theia/node_modules/@theia/php
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section

ERROR: Service 'ide' failed to build: The command '/bin/sh -c yarn --cache-folder ./ycache && rm -rf ./ycache' returned a non-zero code: 1

@pwFoo
Copy link
Author

pwFoo commented Sep 2, 2018

@RVN-BR
I tried to build a image with the plugin, but don't get it work...
Looks like I can't use theia for my needs (php, js, css) because without syntax highlighting and autocomplete it don't make sense.
Have you found a solution?

@svenefftinge
Copy link
Contributor

svenefftinge commented Sep 2, 2018

Did you check the latest version from npm (next)? This change should have removed the vscode warnings.

It works for me at least from within a Gitpod workspace:
https://gitpod.io/github.com/theia-ide/theia-php-extension

@pwFoo
Copy link
Author

pwFoo commented Jan 4, 2019

After some time with other topics, I came across Theia as WebIDE again ...
Is there a docker image / dockerfile for php / js / css?

The needed part would be how to install theia with the theia-php-extension and the start CMD.

@meysholdt
Copy link
Collaborator

I believe what you're looking for is all part of this Dockerfile:
https://github.com/theia-ide/theia-apps/tree/master/theia-full-docker

@pwFoo
Copy link
Author

pwFoo commented Jan 4, 2019

Hi @meysholdt,

thanks for the link.
Tested with a custom dockerfile and package.json.

I have no experience with node / yarn...
Get the following error message at the moment.

dockerfile

FROM node:8-alpine
RUN apk add --no-cache make gcc g++ python
WORKDIR /home/theia
ADD package.json ./package.json
RUN apk add --no-cache php php-zip git composer php-mbstring
RUN yarn --pure-lockfile && \
    yarn theia build && \
    yarn --production && \
    yarn autoclean --init && \
    echo *.ts >> .yarnclean && \
    echo *.ts.map >> .yarnclean && \
    echo *.spec.* >> .yarnclean && \
    yarn autoclean --force && \
    rm -rf ./node_modules/electron && \
    yarn cache clean

FROM node:8-alpine
# See : https://github.com/theia-ide/theia-apps/issues/34
RUN addgroup theia && \
    adduser -G theia -s /bin/sh -D theia;
RUN chmod g+rw /home && \
    mkdir -p /home/project && \
    chown -R theia:theia /home/theia && \
    chown -R theia:theia /home/project;
RUN apk add --no-cache git openssh bash php php-zip composer php-mbstring
ENV HOME /home/theia
WORKDIR /home/theia
COPY --from=0 --chown=theia:theia /home/theia /home/theia
EXPOSE 3000
ENV SHELL /bin/bash
ENV USE_LOCAL_GIT true
USER theia
ENTRYPOINT [ "node", "/home/theia/src-gen/backend/main.js", "/home/project", "--hostname=0.0.0.0" ]

package.json

{
    "private": true,
    "dependencies": {
        "typescript": "latest",
        "@theia/tslint": "next",
        "@theia/typescript": "next",
        "@theia/navigator": "next",
        "@theia/terminal": "next",
        "@theia/outline-view": "next",
        "@theia/preferences": "next",
        "@theia/messages": "next",
        "@theia/getting-started": "next",
        "@theia/git": "next",
        "@theia/file-search": "next",
        "@theia/markers": "next",
        "@theia/preview": "next",
        "@theia/callhierarchy": "next",
        "@theia/merge-conflicts": "next",
        "@theia/search-in-workspace": "next",
        "@theia/json": "next",
        "@theia/textmate-grammars": "next",
        "@theia/mini-browser": "next",
        "@theia/editor-preview": "next",
        "@theia/php": "next"
    },
    "devDependencies": {
        "@theia/cli": "next"
    }
}

Build error

info No lockfile found.
[1/4] Resolving packages...
warning @theia/typescript > @theia/core > inversify@4.14.0: Re-Released as 5.0.1
warning @theia/typescript > @theia/core > electron > electron-download > nugget > progress-stream > through2 > xtend > object-keys@0.4.0: 
warning @theia/typescript > @theia/filesystem > trash > xdg-trashdir > @sindresorhus/df > execa > cross-spawn-async@2.2.5: cross-spawn no longer requires a build toolchain, use it instead
warning @theia/php > @theia/core > inversify@4.14.0: Re-Released as 5.0.1
warning @theia/cli > @theia/application-manager > webpack-cli > jscodeshift > nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
warning @theia/cli > @theia/application-manager > webpack-cli > webpack-addons > jscodeshift > nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
warning @theia/cli > @theia/application-manager > less > request > hawk > hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
warning @theia/cli > @theia/application-manager > less > request > hawk > sntp > hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
warning @theia/cli > @theia/application-manager > less > request > hawk > cryptiles@2.0.5: This version is no longer maintained. Please upgrade to the latest version.
warning @theia/cli > @theia/application-manager > webpack-cli > jscodeshift > babel-preset-es2015@6.24.1: 🙌  Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update! 
warning @theia/cli > @theia/application-manager > webpack-cli > webpack-addons > jscodeshift > babel-preset-es2015@6.24.1: 🙌  Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update! 
warning @theia/cli > @theia/application-manager > less > request > hawk > boom@2.10.1: This version is no longer maintained. Please upgrade to the latest version.
warning @theia/cli > @theia/application-manager > less > request > hawk > cryptiles > boom@2.10.1: This version is no longer maintained. Please upgrade to the latest version.
warning @theia/cli > @theia/application-manager > less > request > hawk > boom > hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
warning @theia/cli > @theia/application-manager > css-loader > cssnano > autoprefixer > browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning @theia/cli > @theia/application-manager > css-loader > cssnano > postcss-merge-rules > browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning @theia/cli > @theia/application-manager > css-loader > cssnano > postcss-merge-rules > caniuse-api > browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
[2/4] Fetching packages...
warning monaco-languageclient@0.9.0: The engine "vscode" appears to be invalid.
warning vscode-base-languageclient@4.4.0: The engine "vscode" appears to be invalid.
info fsevents@1.2.4: The platform "linux" is incompatible with this module.
info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "@theia/tslint > tslint-language-service@0.9.9" has incorrect peer dependency "typescript@>= 2.3.1 < 3".
warning "@theia/tslint > tslint-language-service@0.9.9" has unmet peer dependency "tslint@>= 4 < 6".
warning "@theia/cli > @theia/application-manager > font-awesome-webpack@0.0.5-beta.2" has unmet peer dependency "font-awesome@>=4.3.0".
[4/4] Building fresh packages...
error /home/theia/node_modules/@theia/php: Command failed.
Exit code: 1
Command: composer install
Arguments: 
Directory: /home/theia/node_modules/@theia/php
Output:
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 15 installs, 0 updates, 0 removals
  - Installing webmozart/assert (1.3.0): Downloading (100%)         
  - Installing webmozart/path-util (2.3.0): Downloading (100%)         
  - Installing webmozart/glob (4.1.0): Downloading (100%)         
  - Installing sabre/uri (2.1.1): Downloading (100%)         
  - Installing sabre/event (5.0.3): Downloading (100%)         
  - Installing psr/log (1.0.2): Downloading (100%)         
  - Installing phpdocumentor/reflection-common (1.0.1): Downloading (100%)         
  - Installing phpdocumentor/type-resolver (0.4.0): Downloading (100%)         
  - Installing phpdocumentor/reflection-docblock (4.3.0): Downloading (100%)         
  - Installing netresearch/jsonmapper (v1.4.0): Downloading (100%)         
  - Installing microsoft/tolerant-php-parser (v0.0.12): Downloading (100%)         
  - Installing jetbrains/phpstorm-stubs (dev-master 1508824): Cloning 1508824b38 from cache
  - Installing felixfbecker/advanced-json-rpc (v3.0.1): Downloading (100%)         
  - Installing composer/xdebug-handler (1.1.0): Downloading (100%)         
  - Installing felixfbecker/language-server (v5.4.1): Downloading (100%)         
Generating autoload files
> LanguageServer\ComposerScripts::parseStubs
Parsing file:///home/theia/node_modules/%40theia/php/vendor/jetbrains/phpstorm-stubs/Core/Core.php
Script LanguageServer\ComposerScripts::parseStubs handling the parse-stubs event terminated with an exception

                                                                                                                   
  [ErrorException]                                                                                                 
  Use of undefined constant T_CLASS_C - assumed 'T_CLASS_C' (this will throw an Error in a future version of PHP)  
                                                                                                                   

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
The command '/bin/sh -c yarn --pure-lockfile &&     yarn theia build &&     yarn --production &&     yarn autoclean --init &&     echo *.ts >> .yarnclean &&     echo *.ts.map >> .yarnclean &&     echo *.spec.* >> .yarnclean &&     yarn autoclean --force &&     rm -rf ./node_modules/electron &&     yarn cache clean' returned a non-zero code: 1

@pwFoo
Copy link
Author

pwFoo commented Jan 9, 2019

Tried again and error message changed...

error Couldn't find any versions for "@theia/output" that matches "0.4.0-next.0a6abc41"

@4oo4
Copy link

4oo4 commented Jan 27, 2019

There's something funky going on with what's published out on the NPM registry versus the repo here. The NPM registry package appears to be missing the composer.json that it wants to use after installing the module with yarn.

After inspecting an intermediate container, the @theia/php package fails because the package.json is different from what's in the repo. So until that package includes the composer files it will keep failing.

theia@6f644cd82a69:~/node_modules/@theia/php$ cat package.json
{
  "name": "@theia/php",
  "keywords": [
    "theia-extension"
  ],
  "version": "0.1.0-next.917d6e56",
  "files": [
    "data",
    "lib",
    "src"
  ],
  "dependencies": {
    "@theia/core": "next",
    "@theia/monaco": "next"
  },
  "devDependencies": {
    "lerna": "2.4.0",
    "rimraf": "latest",
    "typescript": "latest"
  },
  "publishConfig": {
    "access": "public"
  },
  "scripts": {
    "prepare": "yarn run clean && yarn run build",
    "postinstall": "composer install",
    "clean": "rimraf lib",
    "build": "tsc",
    "watch": "tsc -w"
  },
  "theiaExtensions": [
    {
      "frontend": "lib/browser/theia-php-frontend-module",
      "backend": "lib/node/theia-php-backend-module"
    }
  ]
}

I'm going to open a separate issue to see if we can get that updated, and also see if I can publish my own package as a workaround with the newer package.json.

#13

@4oo4
Copy link

4oo4 commented Jan 27, 2019

I published a package from the latest commit here:

https://www.npmjs.com/package/theia-php-extension

However, when I try to replace the "@theia/php": "latest", with "theia-php-extension":"0.0.0", I get this error when I actually try to load Theia, since I think I broke the module scope:

selection_006

I'm not familiar enough with node or the internals of Theia to know how to fix that, maybe someone else does? Hopefully @meysholdt can just update the NPM package so we don't have to mess with any of that. Until that happens we'll probably have to install it manually instead of just being able to include the extension in the docker build.

@meysholdt
Copy link
Collaborator

The package "@theia/php":"next" is updated now. Can you try again?

@4oo4
Copy link

4oo4 commented Jan 31, 2019

I can confirm that the docker image builds successfully thanks to @meysholdt's update.

The easiest way to get a working image with php is to just change ARG version=latest to ARG version=next, since that package.json includes @theia/php. I would also recommend adding @theia/yaml as well.

In my docker image, I also changed @meysholdt's suggestion here to use a much more recent version of php (I also add a few other php libraries). I can share my full Dockerfile if someone wants that.

Cheers

#PHP
RUN echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu xenial main" > /etc/apt/sources.list.d/ondrej-ubuntu-php-xenial.list

RUN set -ex \
  && for key in \
  14AA40EC0831756756D7F66C4F4EA0AAE5267A6C \
  ; do \
  apt-key adv --keyserver keyserver.ubuntu.com --recv "$key" ; \
  done

RUN apt-get update
RUN apt-get -y install php7.2 curl php-cli unzip php-common php-mbstring php-curl \ 
   php-dev php-fpm php-json php-sqlite3 php-tidy php-xml php-zip php-gd php-mysql php-pgsql


# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
# https://linuxconfig.org/how-to-install-php-composer-on-debian-linux
RUN curl -s -o composer-setup.php https://getcomposer.org/installer \
    && php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
    && rm composer-setup.php

@pwFoo
Copy link
Author

pwFoo commented Jan 31, 2019

I don't have found a working dockerfile and my custom one (see above) still run into an error.

[4/4] Building fresh packages...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error /home/theia/node_modules/@theia/php: Command failed.
Exit code: 1
Command: composer install
Arguments: 
Directory: /home/theia/node_modules/@theia/php
Output:
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 17 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-ctype (v1.10.0): Downloading (100%)         
  - Installing webmozart/assert (1.4.0): Downloading (100%)         
  - Installing webmozart/path-util (2.3.0): Downloading (100%)         
  - Installing webmozart/glob (4.1.0): Downloading (100%)         
  - Installing sabre/uri (2.1.1): Downloading (100%)         
  - Installing sabre/event (5.0.3): Downloading (100%)         
  - Installing psr/log (1.1.0): Downloading (100%)         
  - Installing phpdocumentor/reflection-common (1.0.1): Downloading (100%)         
  - Installing phpdocumentor/type-resolver (0.4.0): Downloading (100%)         
  - Installing phpdocumentor/reflection-docblock (4.3.0): Downloading (100%)         
  - Installing netresearch/jsonmapper (v1.4.0): Downloading (100%)         
  - Installing microsoft/tolerant-php-parser (v0.0.16): Downloading (100%)         
  - Installing jetbrains/phpstorm-stubs (dev-master c19afae): Cloning c19afae231 from cache
  - Installing felixfbecker/language-server-protocol (v1.2.0): Downloading (100%)         
  - Installing felixfbecker/advanced-json-rpc (v3.0.3): Downloading (100%)         
  - Installing composer/xdebug-handler (1.3.2): Downloading (100%)         
  - Installing felixfbecker/language-server (v5.4.6): Downloading (100%)         
symfony/polyfill-ctype suggests installing ext-ctype (For best performance)
Generating autoload files
> LanguageServer\ComposerScripts::parseStubs
Parsing file:///home/theia/node_modules/%40theia/php/vendor/jetbrains/phpstorm-stubs/meta/.phpstorm.meta.php
Script LanguageServer\ComposerScripts::parseStubs handling the parse-stubs event terminated with an exception

                                                                                                                   
  [ErrorException]                                                                                                 
  Use of undefined constant T_CLASS_C - assumed 'T_CLASS_C' (this will throw an Error in a future version of PHP)  
                                                                                                                   

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...

@meysholdt
Copy link
Collaborator

hey @pwFoo, to debug this could you

  1. make the folder theia-php-extension/php available inside your docker container
  2. run composer install in that directory. This triggers installation of all the php components in the same way the Theia-php-extension does during npm install.

This should make it easier to analyse if you have the right php version and all needed php extensions installed in your docker image.

@pwFoo
Copy link
Author

pwFoo commented Jan 31, 2019

php directory is available.

Step 5/21 : RUN ls -lha
 ---> Running in 20fd3a908006
total 64
drwxr-xr-x    4 root     root        4.0K Jan 31 10:03 .
drwxr-xr-x    7 root     root        4.0K Jan 31 10:03 ..
-rw-r--r--    1 root     root           6 Jan 31 10:03 .gitignore
-rw-r--r--    1 root     root         315 Jan 31 10:03 composer.json
-rw-r--r--    1 root     root       29.1K Jan 31 10:03 composer.lock
drwxr-xr-x    2 root     root        4.0K Jan 31 10:03 data
-rw-r--r--    1 root     root         751 Jan 31 10:03 package.json
drwxr-xr-x    5 root     root        4.0K Jan 31 10:03 src
-rw-r--r--    1 root     root         506 Jan 31 10:03 tsconfig.json

Error during compose install

Step 6/21 : RUN composer install
 ---> Running in 493543edd642
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 17 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-ctype (v1.10.0): Downloading (100%)         
  - Installing webmozart/assert (1.4.0): Downloading (100%)         
  - Installing webmozart/path-util (2.3.0): Downloading (100%)         
  - Installing webmozart/glob (4.1.0): Downloading (100%)         
  - Installing sabre/uri (2.1.1): Downloading (100%)         
  - Installing sabre/event (5.0.3): Downloading (100%)         
  - Installing psr/log (1.1.0): Downloading (100%)         
  - Installing phpdocumentor/reflection-common (1.0.1): Downloading (100%)         
  - Installing phpdocumentor/type-resolver (0.4.0): Downloading (100%)         
  - Installing phpdocumentor/reflection-docblock (4.3.0): Downloading (100%)         
  - Installing netresearch/jsonmapper (v1.4.0): Downloading (100%)         
  - Installing microsoft/tolerant-php-parser (v0.0.16): Downloading (100%)         
  - Installing jetbrains/phpstorm-stubs (dev-master c19afae): Cloning c19afae231 from cache
  - Installing felixfbecker/language-server-protocol (v1.2.0): Downloading (100%)         
  - Installing felixfbecker/advanced-json-rpc (v3.0.3): Downloading (100%)         
  - Installing composer/xdebug-handler (1.3.2): Downloading (100%)         
  - Installing felixfbecker/language-server (v5.4.6): Downloading (100%)         
symfony/polyfill-ctype suggests installing ext-ctype (For best performance)
Generating autoload files
> LanguageServer\ComposerScripts::parseStubs
Parsing file:///home/theia/php/vendor/jetbrains/phpstorm-stubs/meta/.phpstorm.meta.php
Script LanguageServer\ComposerScripts::parseStubs handling the parse-stubs event terminated with an exception

                                                                                                                   
  [ErrorException]                                                                                                 
  Use of undefined constant T_CLASS_C - assumed 'T_CLASS_C' (this will throw an Error in a future version of PHP)  
                                                                                                                   

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...

@romanrehacek
Copy link

I can share my full Dockerfile if someone wants that.

@4oo4 can you share your Docker file and package.json please?

@4oo4
Copy link

4oo4 commented Feb 12, 2019

@romanrehacek Sure:

Dockerfile:

FROM ubuntu:16.04

#Common deps
RUN apt-get update && apt-get -y install curl xz-utils wget

#Install node and yarn
#From: https://github.com/nodejs/docker-node/blob/6b8d86d6ad59e0d1e7a94cec2e909cad137a028f/8/Dockerfile

# gpg keys listed at https://github.com/nodejs/node#release-keys
RUN set -ex \
  && for key in \
  94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
  FD3A5288F042B6850C66B31F09FE44734EB7990E \
  71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
  DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
  C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
  B9AE9905FFD7803F25714661B63B535A4C206CA9 \
  56730D5401028683275BD23C23EFEFE93C4CFFFE \
  77984A986EBC2AA786BC0F66B01FBB92821C587A \
  ; do \
  gpg --keyserver keyserver.ubuntu.com --recv-keys "$key" || \
  gpg --keyserver keyserver.ubuntu.com --recv-keys "$key" || \
  gpg --keyserver pool.sks-keyservers.net --recv-keys "$key" || \
  gpg --keyserver pgp.mit.edu --recv-keys "$key" || \
  gpg --keyserver keyserver.pgp.com --recv-keys "$key" || \
  gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" ; \
  done
  

ENV NODE_VERSION 8.12.0

RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
  && case "${dpkgArch##*-}" in \
  amd64) ARCH='x64';; \
  ppc64el) ARCH='ppc64le';; \
  s390x) ARCH='s390x';; \
  arm64) ARCH='arm64';; \
  armhf) ARCH='armv7l';; \
  i386) ARCH='x86';; \
  *) echo "unsupported architecture"; exit 1 ;; \
  esac \
  && curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
  && curl -SLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
  && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
  && grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
  && tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
  && rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
  && ln -s /usr/local/bin/node /usr/local/bin/nodejs

ENV YARN_VERSION 1.9.4

RUN set -ex \
  && for key in \
  6A010C5166006599AA17F08146C2130DFD2497F5 \
  ; do \
  gpg --keyserver pool.sks-keyservers.net --recv-keys "$key" || \
  gpg --keyserver pgp.mit.edu --recv-keys "$key" || \
  gpg --keyserver keyserver.pgp.com --recv-keys "$key" || \
  gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" ; \
  done \
  && curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
  && curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
  && gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
  && mkdir -p /opt/yarn \
  && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/yarn --strip-components=1 \
  && ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \
  && ln -s /opt/yarn/bin/yarn /usr/local/bin/yarnpkg \
  && rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz

#Developer tools

## Git and sudo (sudo needed for user override)
RUN apt-get -y install git sudo

## cli utils added for convenience
RUN apt-get -y install git sudo nano moreutils jq bc

#LSPs

##GO

#Required to use go get with git source
RUN apt-get update && apt-get install -y git

ENV GO_VERSION 1.9.4
ENV GOPATH=/usr/local/go-packages
ENV GO_ROOT=/usr/local/go
ENV PATH $PATH:/usr/local/go/bin
ENV PATH $PATH:${GOPATH}/bin

RUN curl -sS https://storage.googleapis.com/golang/go$GO_VERSION.linux-amd64.tar.gz | tar -C /usr/local -xzf -
RUN go get -u -v github.com/ramya-rao-a/go-outline
RUN go get -u -v github.com/acroca/go-symbols
RUN go get -u -v github.com/nsf/gocode
RUN go get -u -v github.com/rogpeppe/godef
RUN go get -u -v golang.org/x/tools/cmd/godoc
RUN go get -u -v github.com/zmb3/gogetdoc
RUN go get -u -v golang.org/x/lint/golint
RUN go get -u -v github.com/fatih/gomodifytags
RUN go get -u -v github.com/uudashr/gopkgs/cmd/gopkgs
RUN go get -u -v golang.org/x/tools/cmd/gorename
RUN go get -u -v sourcegraph.com/sqs/goreturns
RUN go get -u -v github.com/cweill/gotests/...
RUN go get -u -v golang.org/x/tools/cmd/guru
RUN go get -u -v github.com/josharian/impl
RUN go get -u -v github.com/haya14busa/goplay/cmd/goplay
RUN go get -u -v github.com/davidrjenni/reftools/cmd/fillstruct

#Java
RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
RUN apt-get update && apt-get -y install openjdk-8-jdk


#C/C++
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
# public LLVM PPA, development version of LLVM
RUN echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial main" > /etc/apt/sources.list.d/llvm.list
RUN apt-get update && apt-get install -y clang-tools-9
RUN ln -s /usr/bin/clangd-9 /usr/bin/clangd

#Python 2
RUN apt-get update && apt-get install -y python python-pip && \
pip install python-language-server;

#Python 3
RUN apt-get update && apt-get install -y python python-pip python3 python3-pip


#PHP
RUN echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu xenial main" > /etc/apt/sources.list.d/ondrej-ubuntu-php-xenial.list

RUN set -ex \
  && for key in \
  14AA40EC0831756756D7F66C4F4EA0AAE5267A6C \
  ; do \
  apt-key adv --keyserver keyserver.ubuntu.com --recv "$key" ; \
  done

RUN apt-get update
RUN apt-get -y install php7.2 curl php-cli unzip php-common php-mbstring php-curl \ 
   php-dev php-fpm php-json php-sqlite3 php-tidy php-xml php-zip php-gd php-mysql php-pgsql


# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
# https://linuxconfig.org/how-to-install-php-composer-on-debian-linux
RUN curl -s -o composer-setup.php https://getcomposer.org/installer \
    && php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
    && rm composer-setup.php

#Ruby
RUN apt-get -y install ruby ruby-dev zlib1g-dev
RUN gem install solargraph


## User account
RUN adduser --disabled-password --gecos '' theia && \
  adduser theia sudo && \
  echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers;

RUN chmod g+rw /home && \
  mkdir -p /home/project && \
  chown -R theia:theia /home/theia && \
  chown -R theia:theia /home/project;

#Theia
##Needed for node-gyp, nsfw build
RUN apt-get update && apt-get install -y python build-essential

USER theia
ARG version=next
WORKDIR /home/theia
ADD $version.package.json ./package.json
ARG GITHUB_TOKEN
RUN yarn --cache-folder ./ycache && rm -rf ./ycache
# using "NODE_OPTIONS=..." to avoid out-of-memory problem in CI
RUN NODE_OPTIONS="--max_old_space_size=4096" yarn theia build
EXPOSE 3000
ENV SHELL /bin/bash

ENTRYPOINT [ "yarn", "theia", "start", "/home/project", "--hostname=0.0.0.0" ]

Package.json

{
    "private": true,
    "dependencies": {
        "typescript": "next",
        "@theia/callhierarchy": "next",
        "@theia/core": "next",
        "@theia/cpp": "next",
        "@theia/docker": "next",
        "@theia/editor": "next",
        "@theia/editorconfig": "next",
        "@theia/editor-preview": "next",
        "@theia/extension-manager": "next",
        "@theia/file-search": "next",
        "@theia/filesystem": "next",
        "@theia/git": "next",
        "@theia/go": "next",
        "@theia/getting-started": "next",
        "@theia/java": "next",
        "@theia/json": "next",
        "@theia/keymaps": "next",
        "@theia/languages": "next",
        "@theia/markers": "next",
        "@theia/merge-conflicts": "next",
        "@theia/messages": "next",
        "@theia/metrics": "next",
        "@theia/mini-browser": "next",
        "@theia/monaco": "next",
        "@theia/navigator": "next",
        "@theia/outline-view": "next",
        "@theia/output": "next",
        "@theia/php": "next",
        "@theia/plantuml": "next",
        "@theia/plugin": "next",
        "@theia/plugin-ext": "next",
        "@theia/plugin-ext-vscode": "next",
        "@theia/preferences": "next",
        "@theia/preview": "next",
        "@theia/process": "next",
        "@theia/python": "next",
        "@theia/ruby": "next",
        "@theia/rust": "next",
        "@theia/search-in-workspace": "next",
        "@theia/task": "next",
        "@theia/terminal": "next",
        "@theia/textmate-grammars": "next",
        "@theia/tslint": "next",
        "@theia/typescript": "next",
        "@theia/userstorage": "next",
        "@theia/variable-resolver": "next",
        "@theia/workspace": "next",
        "@theia/yaml": "next",
        "theia-yang-extension": "next"
    },
    "devDependencies": {
        "@theia/cli": "next"
    }
}

The version of Theia you get will be different than what I originally built, since I think the next tag is essentially a nightly?

@romanrehacek
Copy link

romanrehacek commented Feb 12, 2019

@4oo4 I just created my own Theia-php Dockerfile.
Theia-full has 2.85GB, my image has 948MB. You can try it.
https://hub.docker.com/r/noxonx/theia-php-docker

@4oo4
Copy link

4oo4 commented Feb 13, 2019

@romanrehacek Awesome, thanks! I'll test that out when I get a chance. Didn't even know about jessie-slim being a thing, probably much easier to rebuild an image on that versus Alpine.

@rhildred
Copy link

@romanrehacek Your code worked for me. I set my own timezone america/toronto and was off. What a world we live in!!!!

@rhildred
Copy link

So 2 hours later and I have to give up on getting python to also work. I can get python to work on it's own. I can run pyls in your container and that works. Python doesn't even show up as a language even though I have @theia/python installed.

Python and the code spell checker from street software vscode plugin are all I need to make my lab environment complete. Anyone have any ideas?

@rhildred
Copy link

Python doesn't work in theia-full-docker either. Even though it works in theia-python-docker.

@4oo4
Copy link

4oo4 commented Feb 13, 2019

@rhildred Did you install the python language server? Look at my dockerfile for the python packages needed, you should need python, pip, and then run pip install python-language-server. That's needed for Intellisense to work with Python.

@rhildred
Copy link

@4oo4 Yes, I installed the python language server. In the working python dockerfile:

RUN pip install \
    python-language-server[all] \
    flake8 \
    autopep8

When I tried to integrate it with your working php dockerfile I had to also add futures to get pyls to work in a terminal window. I am going to try again to add your php stuff to the working python one. 2.85 gb and still no python is too big for me (I need 120 simultaneous users).

Any ideas how to get the vscode StreetSide software code spell checker integrated? Right now I have 30 students writing wordpress plugins. I don't have python again until next September. I see in the theia-full-docker the package "@theia/plugin-ext-vscode": "next",. There is also an article about testing vscode plugins here. (https://github.com/theia-ide/theia/wiki/Testing-VS-Code-extensions)

@rhildred
Copy link

@4oo4 call me a newbie but I forgot that I am running behind cloudflare and didn't turn on development mode. I do have an error:


Uncaught (in promise) Error: Request getExtensionsInfos failed with message: EACCES: permission denied, open '/home/theia/.application-module-loader.js'
    at Proxy.<anonymous> (proxy-factory.ts:232)
    at n.<anonymous> (about-dialog.ts:65)
    at shell-layout-restorer.ts:56
    at Object.next (shell-layout-restorer.ts:56)
    at a (shell-layout-restorer.ts:56)

but it looks like your Dockerfile should fix that. I will try again to merge the 2 in about 1 hour's time.

@rhildred
Copy link

@4oo4 It was the cloudflare all along. I added a rule to do cache-level: bypass and everything is working:

In package.json

        "@theia/php": "next",
+        "@theia/python": "next",

and in Dockerfile

      && apt install -y --no-install-recommends php7.2-cli php7.2-curl php7.2-json php7.2-mbstring \
+    && apt install -y --no-install-recommends python-dev python-pip python3 python3-pip \

...

+ RUN pip install -U setuptools \
+    && pip install \
+    python-language-server[all] \
+    flake8 \
+    autopep8 \
+    futures


@4oo4
Copy link

4oo4 commented Feb 16, 2019

@rhildred Awesome, good to know!

@designerbase
Copy link

@4oo4 I just created my own Theia-php Dockerfile.
Theia-full has 2.85GB, my image has 948MB. You can try it.
https://hub.docker.com/r/noxonx/theia-php-docker

Hi @romanrehacek i used your dockerfile and build one new image, but when i try to run from the new image still the php syntax are not highlighting, i used same dockerfile and package.json. is there anything else to configure??
but when i run from your image the requirement works perfectly. i mean the php syntax hightlight.. please gimme a fix..

@rhildred
Copy link

rhildred commented May 28, 2019

I built @romanrehacek's Dockerfile 3 months ago right after he did it and can verify that everything worked in it.

When I build it now php syntax highlighting doesn't work. The git plugin also stopped working in the last few days as well as the find in files plugin.

My theory is that @romanrehacek's work was based on Theia next. This was important because there was a composer issue with Theia/PHP and the latest build. Perhaps next has breaking changes in it. My thinking was I would try latest again. Next week when my consulting gig is done.

@designerbase
Copy link

@rhildred so do we need to wait for the latest build?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants