Skip to content

Commit

Permalink
fix: clarify documentation for container sandboxes (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
CompuIves authored Nov 15, 2023
1 parent fa82c99 commit 0d084eb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ authors: ['CompuIves']
description: You can configure sandboxes and templates with configuration files.
---

import { Callout } from 'nextra-theme-docs'

# Configuration

## Configuration Files
Expand Down Expand Up @@ -35,6 +37,16 @@ support these options:
| `template` | Which sandbox template to use | [see here](https://github.com/codesandbox/codesandbox-importers/blob/master/packages/types/index.d.ts#L39-L64) | smart detection, w/ fallback to `"create-react-app"` |
| `view` | Which view to show first in the preview | Client: `"browser"` / `"console"` / `"problems"` / `"tests"`<br />Container: `"browser"` / `"console"` / `"problems"` / `"terminal"` | `"browser"` |
| `disableLogging` | Whether we should disable in-browser logging and have all logs created by the sandbox go to the browser console | `true` / `false` | `false` |


### Container Configuration

<Callout type="warning">
Container Sandboxes are deprecated for [Cloud Sandboxes](/learn/sandboxes/overview). You can find more info about configuring Cloud Sandboxes [here](/learn/environment/devcontainers).
</Callout>

| Option | Description | Possible Values | Default Value |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- |
| `container` | The container object contains the port, start script and Node.js major version, for example: `"container": { "port": 3212, "startScript": "custom", "node": "14" }` |
| `port` | The main port which the browser window listens to | 1024 - 65535 | First opened port inside the container. |
| `startScript` | Explicitly specify the start script used in a container sandbox, overriding the default value | A String matching a script name defined under `"scripts"` in `package.json` | `"dev"` / `"develop"` / `"serve"` / `"start"` |
Expand Down
28 changes: 27 additions & 1 deletion packages/projects-docs/pages/learn/environment/devcontainers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,30 @@ Some properties within the Dev Container configuration may behave differently co
- `capAdd`: CodeSandbox does not support adding all capabilities. As the containers are run as a non-root user, capabilities that need root access will not work.
- `features`: CodeSandbox automatically adds docker-cli to the container and connects to the host socket. Features like docker-in-docker and docker-outside-of-docker will work a bit differently. As the docker-cli and socket from host are accessible in the container, most use cases should work as expected.
- `${localEnv:VARIABLE_NAME}` Any For CodeSandbox, the host is in the cloud rather than in your local machine.
hostRequirements: CodeSandbox does not yet support this property.
hostRequirements: CodeSandbox does not yet support this property.

## Examples

Here are some example devcontainer configurations that you can use for configuring your environment.

### Node v18

Create a `.devcontainer/devcontainer.json` with these contents:

```json
{
"name": "Node.js",
"image": "mcr.microsoft.com/devcontainers/javascript-node:18"
}
```

### Node v20

Create a `.devcontainer/devcontainer.json` with these contents:

```json
{
"name": "Node.js",
"image": "mcr.microsoft.com/devcontainers/javascript-node:20"
}
```

1 comment on commit 0d084eb

@vercel
Copy link

@vercel vercel bot commented on 0d084eb Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.