|
| 1 | + |
| 2 | + |
| 3 | +====================== |
| 4 | +Develop on a container |
| 5 | +====================== |
| 6 | + |
| 7 | +This guide guides you on how to develop PyMAPDL features or fix bugs using |
| 8 | +a `remote container <https://code.visualstudio.com/docs/devcontainers/containers>`_ |
| 9 | +or `Codespaces <https://github.com/features/codespaces>`_. |
| 10 | +The files for setting up the container can be found in the |
| 11 | +`.devcontainer directory <https://github.com/pyansys/pymapdl/tree/main/.devcontainer>`_. |
| 12 | + |
| 13 | +About the MAPDL container |
| 14 | +========================= |
| 15 | + |
| 16 | +Because MAPDL software is not open source, the GPL license does not allow to |
| 17 | +distribute a docker container to users. |
| 18 | +Having a docker container with MAPDL installed is a requirement to use |
| 19 | +any of the development methods mentioned on this section. |
| 20 | +If you want to build your own docker image, visit the following link |
| 21 | +:ref:`ref_make_container`. |
| 22 | + |
| 23 | + |
| 24 | +Develop on a remote container |
| 25 | +============================= |
| 26 | + |
| 27 | +.. note:: If you are an Ansys employee or collaborator and want to use this development method, please email [email protected]. |
| 28 | + |
| 29 | +To use a `remote container <https://code.visualstudio.com/docs/devcontainers/containers>`_, you must install: |
| 30 | + |
| 31 | +* `VS Code <https://code.visualstudio.com>`_ |
| 32 | +* `Docker software <https://www.docker.com>`_ or equivalent. |
| 33 | + It is recommended to use Windows Subsystem Linux (WSL) backend to run Linux docker containers. |
| 34 | + See `Developing inside a Container Getting started <https://code.visualstudio.com/docs/devcontainers/containers#_getting-started>`_ |
| 35 | + for more information. |
| 36 | +* `Remove Development VS Code extension pack <https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack>`_ |
| 37 | + |
| 38 | +As mentioned before, you must have your own Docker image with MAPDL installed locally available or hosted in an |
| 39 | +online registry, i.e. GitHub `ghcr.io <https://github.com/features/packages>`_. |
| 40 | +For the purpose of this document, assume your image is hosted at ``ghcr.io/myaccount/mapdlimage:mytag``. |
| 41 | + |
| 42 | +You must then modify the file `docker-compose.yml <https://github.com/pyansys/pymapdl/tree/main/.devcontainer/docker-compose.yml>`_ |
| 43 | +with your custom image: |
| 44 | + |
| 45 | +.. code-block:: yaml |
| 46 | + :emphasize-lines: 4 |
| 47 | +
|
| 48 | + ports: |
| 49 | + - '50052:50052' |
| 50 | + - '50055:50055' |
| 51 | + image: 'ghcr.io/myaccount/mapdlimage:mytag' |
| 52 | + user: "0:0" |
| 53 | + volumes: |
| 54 | +
|
| 55 | +
|
| 56 | +.. warning:: Also you might need to change some environment variables or Docker options to adjust to your image configuration. |
| 57 | + Be careful to not commit those changes in your PRs. |
| 58 | + |
| 59 | +You can now open the current folder (or PyMAPDL repository) using |
| 60 | +``ctr/cmd`` + ``shift`` + ``p`` to open the VSCode *Command palette*. |
| 61 | +Then select ``Dev Containers: Open Folder in Container``. |
| 62 | +Because the configuration is available in ``.devcontainer`` directory, VS Code will automatically |
| 63 | +launch the MAPDL container with the desired configuration. |
| 64 | + |
| 65 | +You can now work normally, but you will be, in fact, working from inside the container. |
| 66 | +Because VSCode mount the local directory into the docker container, you don't lose your changes if accidentally |
| 67 | +delete your container. |
| 68 | +However, this mounting process might have a significant impact on the container performance, especially noticeable |
| 69 | +if you are using MacOS. |
| 70 | +You can avoid that by cloning the repository inside the container. |
| 71 | +Visit `Quick start: Open a Git repository or GitHub PR in an isolated container volume <https://code.visualstudio.com/docs/devcontainers/containers#_quick-start-open-a-git-repository-or-github-pr-in-an-isolated-container-volume>`_ |
| 72 | +for more information. |
| 73 | + |
| 74 | + |
| 75 | +License |
| 76 | +------- |
| 77 | + |
| 78 | +As mentioned before, you must have a valid license to run MAPDL. |
| 79 | +When you launch the container, the file ``script.sh`` automatically checks if the environment |
| 80 | +variable ``ANSYSLMD_LICENSE_FILE`` exists. |
| 81 | +This environment variable sets the port and IP address of the license server. |
| 82 | + |
| 83 | +If you do not have set this environment variable before launching the container, you are prompt to enter |
| 84 | +your license server port and address. |
| 85 | + |
| 86 | +You can set your license using the environment variable ``ANSYSLMD_LICENSE_FILE`` from the terminal before launching |
| 87 | +VS Code. This is recommended if you are using Windows OS. |
| 88 | +For example, if you have a license server at the address ``123.45.67.89``, you can set the license using: |
| 89 | + |
| 90 | +.. code:: pwsh |
| 91 | + |
| 92 | + $env:ANSYSLMD_LICENSE_FILE = '[email protected]' |
| 93 | + code . # launch VS Code |
| 94 | +
|
| 95 | +And then open the folder in the container using the *Command palette*. |
| 96 | + |
| 97 | + |
| 98 | +Develop on Codespaces |
| 99 | +===================== |
| 100 | + |
| 101 | +Codespaces is a virtual delopment environment provided by GitHub. |
| 102 | +You can launch a container which all the required tools and start to work in couple of minutes. |
| 103 | +This is an easy way to get started with PyMAPDL development. |
| 104 | + |
| 105 | +.. warning:: This method is only applicable and allowed to Ansys employees or collaborators. |
| 106 | + If you are an Ansys employee and wants use this development method, please email [email protected]. |
0 commit comments