LogoFreestyle

VM Configuration

Overview of all configuration options for Freestyle VMs.

When creating a VM, you can configure many aspects of its behavior and contents. This section covers all available configuration options.

Quick Reference

OptionDescriptionPage
additionalFilesAdd files to the VM filesystemFiles and Repos
gitReposClone git repositoriesFiles and Repos
systemdDefine background services and startup tasksSystemd Services
portsExpose services to the internetPorts and Networking
usersCreate Linux usersUsers and Groups
groupsCreate Linux groupsUsers and Groups
persistenceControl VM storage strategyPersistence
idleTimeoutSecondsAuto-suspend after inactivityLifecycle
rootfsSizeGbRoot filesystem sizeLifecycle
workdirDefault working directoryLifecycle
waitForReadySignalWait for VM to be fully readyLifecycle
recreateAllow automatic recreationLifecycle

Configuration Methods

Direct Configuration

Pass options directly to freestyle.vms.create():

const { vm } = await freestyle.vms.create({
  workdir: "/app",
  idleTimeoutSeconds: 600,
  additionalFiles: {
    "/app/config.json": { content: "{}" },
  },
});

Using Templates

Put configuration in a VmTemplate for automatic caching:

import { VmTemplate } from "freestyle-sandboxes";

const template = new VmTemplate({
  workdir: "/app",
  gitRepos: [{ repo: "owner/app", path: "/app" }],
  systemd: {
    services: [
      { name: "web", mode: "service", exec: ["npm start"], workdir: "/app" },
    ],
  },
});

// First call builds and caches the template
const { vm } = await freestyle.vms.create({ template });

// Subsequent calls are instant
const { vm: vm2 } = await freestyle.vms.create({ template });

See Templates and Snapshots for more details on caching.

Combining Both

Apply dynamic configuration on top of a template:

const { vm } = await freestyle.vms.create({
  template, // Base configuration (cached)
  // Dynamic config applied on top
  additionalFiles: {
    "/app/.env": { content: `API_KEY=${process.env.API_KEY}` },
  },
  idleTimeoutSeconds: 300,
});

On this page

Freestyle AI

Documentation assistant

Experimental: AI responses may not always be accurate—please verify important details with the official documentation.

How can I help?

Ask me about Freestyle while you browse the docs.