Devcontainer

We are also supporting a containerized setup(docker/podman). For more information checkout the README inside .devcontainer.

Background

Devcontainer allows you to develop using VSCode; without installing Node and Rust, you only need Docker and the Dockercontainer extension.

Prerequisites

To be able to run PermaplanT in a Devcontainer, first you need to make sure you have Docker set up on your machine. If you are on Windows, make sure you also have WSL installed, and then make sure that Docker uses WSL 2 Backend.

You can test that Docker works correctly on your machine by trying to run any docker image, for example this Hello World example.

Also, you will need VS Code installed in your machine.

To open the Devcontainer in VS Code, it's easiest to click on the "Dev Containers Open" tag in the GitLab project readme, or you can access the same link directly here. Allow VS Code to open the link, and the process of setting up the devcontainer will start. (It will take several minutes, as it also needs to download os images and packages from the internet)

Install the extension

Devcontainer extension and choose Dev Containers: Reopen in Container in the VSCode command palette. The devcontainer includes a PgAdmin container on port 5050; see the .devcontainer directory.

Within the devcontainer install all dependencies with

make install

Git user

Globally set git credentials are not available in the devcontainer, set them locally.

git config user.name "Your name"
git config user.email "Your email"

FAQ / Debugging

Git over HTTPS

If you want to use Git over HTTPS / with a GitLab Access Token, you need to switch over the Git Remote of the project, from SSH to HTTPS. You can do this by running the following command:

git remote set-url origin https://gitlab.tuwien.ac.at/permaplant/PermaplanT.git

CRLF / LF

If you are on Windows and you are having trouble with the line endings of your files (for example, when trying to run make install), it might be because of your local Git Config. Docker/Devcontainer uses your local Git Config when cloning the project, so it might be necessary to change the settings for file endings. You can run the following two commands before cloning the project:

git config --global core.autocrlf false
git config --global core.eol lf

If you see any file inside of the project display "CRLF" instead of "LF" in the bottom right corner of VSCode after opening it, the cloning step has already failed and converted every file to the windows CRLF format. To avoid this, it is recommended to clone the project directly through the devcontainer link.

Removing old containers / clearing cache

If the devcontainer setup does not seem to work or you applied changes/fixes that don't seem like they're working, you can try removing PermaplanT containers in docker to "clear the cache". To do so, remove permaplant_devcontainer under the "Containers" tab in Docker, remove permaplant_devcontainer_app, dpage/pgadmin4 and postgis/postgis under "Images", everything containing the "Permaplant" prefix under "Volumes" and remove all of the builds under the "Builds" tab.

Alternatively/additionally, you can also try pressing f1 inside of VSCode and typing "rebuild" and executing the "Dev Containers: Rebuild Container" command.