Platform Independent Local Dev Guide for Typescript development

I know this post is old but for the future visitors, here is a guide I put together for my team. My guide leverages DevContainers which is platform independent.

Summary

Palantir Foundry provides the capability to let you work with your Code Repositories on your local computer instead of being stuck in their web IDE. The main benefit of doing this is that you can work in a familiar IDE and more importantly, you can leverage Cursor to help you develop.

Palantir Docs cover Python Local Development (even though Python support is still in Beta) but TypeScript local Development is also possible. This guide will focus on TypeScript local Development.

DevContainers

This guide will leverage Development containers. Using DevContainers allows us to:

  • Maintain platform independence
    • This guide will work for Mac and Windows
  • Maintain a clean environment for your local host and each repo
    • Palantir currently uses Node 18
  • A one-click Dev Environment Setup for incoming Engineers.

Pre-Requisites

  1. Docker Desktop
  2. IDE of choice:
    • https://code.visualstudio.com/
    • https://www.cursor.com/
  3. DevContainer IDE Extension

Setup

Web IDE

In a new or existing Code Repo, Add a top level folder called .devcontainer and a file inside that folder titled devcontainer.json. Copy this code into devcontainer.json

// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/java
{
    "name": "Java",
    // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
    "image": "mcr.microsoft.com/devcontainers/java:1-17-bookworm",
    "features": {
        "ghcr.io/devcontainers/features/java:1": {
            "version": "none",
            "installMaven": "false",
            "installGradle": "true"
        },
        "ghcr.io/devcontainers-community/npm-features/typescript:1": {}
    },
    // Use 'forwardPorts' to make a list of ports inside the container available locally.
    // "forwardPorts": [],
    // Use 'postCreateCommand' to run commands after the container is created.
    "postCreateCommand": "./gradlew localDev",
    // Configure tool-specific properties.
    // "customizations": {},
    // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
    // "remoteUser": "root"
}

This DevContainer file defines a base Java image (so you can leverage Palantir’s gradle scripts) with an added TypeScript feature to support TypeScript development.

Commit these changes on the web IDE.

Local

On the web IDE, click the Work Locally button in the top right and copy the Git URL

On your local machine, in your desired folder, run:

> git clone <copied-git-url>

Open the repo using your IDE. You should see a pop up saying that it found a DevContainer configuration:

Click Reopen in Container. Your IDE will now use the devcontainer.json file configuration to fetch the requested images and features and build the full DevContainer.

This will setup your environment and sync down all the necessary custom resources that you added in the Web IDE and give you full intellisense.

Ongoing Development

Now you just develop in the normal git flow. Create a branch, develop on the branch locally, push your changes, create a PR in Foundry and then merge to Main and Release

Ontology/Resource Changes

If you have updated your ontology and/or updated the list of resources you have imported, you will need to run this command from the base repo directory to pick up the latest:

> ./gradlew localDev

Token Expiration

The token that is embedded in the Git URL that Palantir provides does not last forever. Eventually you will start getting auth errors in your git commands. When that happens, retrieve a new Git URL from the web IDE and reset your remote by running this command in your repo:

> git remote set-url origin <copied-git-url>

2 Likes

Having trouble editing the main post so here is a small addition:

Personal Token Alternative

If you want a longer lasting token, you can generate a personal access token and use that in your Git URL. Replaces the text between the : and @ in the Git URL copied from Palantir

Shameless plug: We build a git credentials helper into Foundry DevTools
https://emdgroup.github.io/foundry-dev-tools/api/foundry_dev_tools.cli.git_credential_foundry.html#module-foundry_dev_tools.cli.git_credential_foundry

This will let you to store the token only once in the central fdt config or even use oauth2 configured centrally.

I saw your Foundry DevTools today. Still relatively new to Palantir & Foundry so i don’t quite understand what DevTools does but is your project helpful in developing functions?

Not for functions, but if would help you to store the token only once in a central config and you would not have to update every git url in all of your cloned repo.

If you only have one local repo might be overkill though.