Search code examples
pythoneclipseeclipse-che

Have to keep reinstalling python modules (Eclipse Che)?


For my Eclipse Che project, I have to reinstall my python modules every time I load the workspace (blegh). Is there a way to install the modules my team needs to a global folder so they don't have to even install the python modules every time they want to load the project? Thank you!


Solution

  • Alternatively you can build your workspace from a stack based on a Dockerfile recipe:

    1. First, write down all your installation commands that you execute in Eclipse Che terminal when customising your workspace

    2. Next, create a new Dockerfile based on the one you are currently using

      2.1. find the Dockerfile your current workspace is based on from
      recipes (e.g. for default Python stack it would be this one)

      2.2. modify that file by adding your installation commands from previous step before the last line (EXPOSE 8080) like this:
      RUN sudo -H pip install flask && sudo -H pip install pandas etc...

    3. In Eclipse Che create a new custom stack based on your Dockerfile

      3.1. Click Stacks on the left (below Workspaces) and click “Add Stack”

      3.2. In “Build stack from recipe” dialog select Dockerfile tab and paste there the content of your modified Dockerfile

      3.3. Click OK => new page opens where you can further customise your stack

      3.4. Edit the name and description, then click NEW-MACHINE to set the memory size as you like then click SAVE (right upper corner)

      3.5. Click again NEW-MACHINE to add some essential Agents: “Workspace API”, “Terminal”, “Exec” and other language servers that you need (e.g. “Python language server”)

      3.6 You can customise your stack further by adding environment vars or servers etc…

    4. Hit SAVE and then TEST to test your stack

    5. On the new dialog that opens you can specify some default project to be added than click “Test Workspace”

    6. If workspace will build successfully your will see below message in green “Your workspace is ready to be used” and the stack will be added to the Stacks. Also your new-machine and Terminal will be opened below

    7. Now close “Testing Stack”, go to Workspaces or Dashboard and create a new Workspace

    8. Your newly created stack should be visible there under stacks so you can select it now and build your workspace based on that