Coder.comC
Coder.com10mo ago
29 replies
Igor Zimmer

Is there any way to persist files when restarting a coder workspace?

I’m using coder_agent, and in the startup_script, I have logic that clones a Git repo and runs yarn install. The problem is that the yarn install step takes about 10 minutes, which significantly slows down workspace startup.

However, I only really need this to run the first time the workspace is created — not every time it’s restarted.

I tried adding a check like this:
if [ ! -d "/home/coder/my-repo" ]; then
    echo "Repository not found. Cloning and installing dependencies..."
    git clone https://example.com/my-repo.git /home/coder/my-repo
    cd /home/coder/my-repo
    yarn install
else
    echo "Repository already exists. Skipping setup."
fi


But the condition always returns false (the repo isn't present). Is there a recommended way to run expensive setup steps only on initial workspace creation, and skip them on restarts?

Thanks in advance!
Was this page helpful?