Skip to content
This repository was archived by the owner on Apr 28, 2020. It is now read-only.

Commit 9114ed8

Browse files
Nathan Potternhooyr
Nathan Potter
authored andcommitted
Add more docs
1 parent 7064682 commit 9114ed8

File tree

22 files changed

+349
-188
lines changed

22 files changed

+349
-188
lines changed

.sail/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
FROM codercom/ubuntu-dev-go
2-
RUN sudo apt-get install -y htop hugo
2+
RUN sudo apt-get install -y htop
33
LABEL project_root "~/go/src/go.coder.com"
44

55
# Modules break much of Go's tooling.
66
ENV GO111MODULE=off
7+
8+
# Install the latest version of Hugo.
9+
RUN wget -O /tmp/hugo.deb https://github.com/gohugoio/hugo/releases/download/v0.55.4/hugo_extended_0.55.4_Linux-64bit.deb && \
10+
sudo dpkg -i /tmp/hugo.deb && \
11+
rm -f /tmp/hugo.deb

site/config.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
theme = "sail"
22
languageCode = "en-us"
33
defaultContentLanguage="en"
4-
title = "My New Hugo Site"
4+
title = "Sail"
55

6-
sectionPagesMenu = "main"
6+
sectionPagesMenu = "main"

site/content/docs/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11

22
+++
3+
title="Introduction"
34
+++

site/content/docs/commands/edit.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
type="docs"
33
title="edit"
44
browser_title="Sail - Commands - edit"
5+
section_order=1
56
+++
67

78
```
@@ -46,4 +47,4 @@ Iteration is seamless because
4647
1. `code-server` automatically reconnects the page when the new environment is
4748
created.
4849
1. The project folder is always persisted so WIP changes are safe.
49-
1. UI state is persisted so the exact layout of your editor in undisturbed.
50+
1. UI state is persisted so the exact layout of your editor is undisturbed.

site/content/docs/commands/ls.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
type="docs"
33
title="ls"
44
browser_title="Sail - Commands - ls"
5+
section_order=2
56
+++
67

78
```

site/content/docs/commands/rm.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
+++
2+
type="docs"
3+
title="rm"
4+
browser_title="Sail - Commands - rm"
5+
section_order=3
6+
+++
7+
8+
```
9+
NAME:
10+
sail rm - Remove a sail container from the system.
11+
12+
USAGE:
13+
sail rm [flags] <repo>
14+
15+
DESCRIPTION:
16+
This command allows for removing a single container
17+
or all of the containers on a system with the -all flag.
18+
19+
Flags:
20+
-all Remove all sail containers. (false)
21+
```
22+
23+
The `rm` command lets you remove sail environments from your system.

site/content/docs/commands/run.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
type="docs"
33
title="run"
44
browser_title="Sail - Commands - run"
5+
section_order=0
56
+++
67

78
```
@@ -26,11 +27,12 @@ Flags:
2627
-test-cmd A command to use in-place of starting code-server for testing purposes.
2728
```
2829

29-
The `run` command starts up a container, and plops you into code-server.
30+
The `run` command starts up a container, and opens a browser window pointing to
31+
the project's running code-server.
3032

3133
## Browser
3234

33-
Chrome is always used if it is available, because we can open it in `--app` mode,
34-
which makes the code-server interface feel exactly live native VS Code.
35+
Chrome is always used if it is available, because sail can open it in `--app` mode,
36+
which makes the code-server interface feel exactly like native VS Code.
3537

36-
If Chrome isn't available, we open the URL in the OS's default browser.
38+
If Chrome isn't available, sail opens the URL in the OS's default browser.

site/content/docs/commands/shell.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
type="docs"
33
title="shell"
44
browser_title="Sail - Commands - shell"
5+
section_order=4
56
+++
67

78
```
@@ -15,4 +16,4 @@ DESCRIPTION:
1516
shell drops you into the default shell of a repo container.
1617
```
1718

18-
The `shell` command drops you into the container's shell on the host.
19+
The `shell` command drops you into the container's shell on the host.

site/content/docs/concepts/config.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
type="docs"
33
title="Configuration"
44
browser_title="Sail - Docs - Configuration"
5+
section_order=5
56
+++
67

78
Sail is about moving configuration into controlled projects and hats, so naturally
89
it strives to keep it's configuration minimal. Sail accepts a variety of flags
9-
through it's commands, but there is a little bit global configuration at
10+
through it's commands, but there is a little bit of global configuration located at:
1011

1112
`~/.config/sail/sail.toml`.
1213

13-
The self-documenting default configuration for convenience:
14+
Here is the default self-documenting configuration for reference:
1415

1516
```toml
1617
# default_image is the default Docker image to use if the repository provides none.
@@ -22,4 +23,4 @@ project_root = "~/Projects"
2223

2324
# default hat lets you configure a hat that's applied automatically by default.
2425
# default_hat = ""
25-
```
26+
```

site/content/docs/concepts/docker.md

Lines changed: 36 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,66 @@
1-
21
+++
32
type="docs"
43
title="Docker"
54
browser_title="Sail - Docs - Docker"
6-
draft=true
5+
section_order=4
76
+++
87

98
Sail can be thought of as a wrapper around the Docker toolchain, focused
109
on managing development environments.
1110

1211
It stores most of it's state in the Docker daemon
13-
in the form of metadata and labels.
14-
15-
Informational Sail Docker labels begin with `com.coder.sail`.
16-
17-
## Command labels
12+
in the form of metadata and [labels](/docs/concepts/labels).
1813

19-
Sail artificially extends the Dockerfile syntax through labels.
2014

21-
For example:
22-
23-
```Dockerfile
24-
LABEL project_root "~/go/src"
25-
```
15+
## Immutability
2616

27-
Will instruct Sail to use `~/go/src` as the project root.
17+
Sail tries to encourage a workflow of explicitly describing your development environment in a way
18+
that's easy to share and iterate on.
2819

29-
We call these kinds of labels _command labels_. Each command label is introduced
30-
throughout these docs.
20+
If you want to make a change to the environment, you should modify your [hat](/docs/concepts/hats) or the [project's](/docs/concepts/projects)
21+
Dockerfile.
3122

32-
## Container Naming
33-
34-
Containers are named `<org>-<project>` in Docker, but `<org>/project` in Sail.
35-
36-
## Networking
23+
## Project Defined Environment
3724

38-
### MacOS
25+
Projects can define their own environment by specifying a `.sail/Dockerfile` file.
26+
If a `.sail/Dockerfile` is not present in a repository, the `codercom/ubuntu-dev`
27+
image will be used as the base environment.
3928

40-
On MacOS hosts, the Docker container is given a bridge network.
29+
When specifying a custom project environment, the dev container must have
30+
be an ancestor of `codercom/ubuntu-dev` in order to have the proper dependencies
31+
setup.
4132

42-
### Linux
33+
When building the project's image, the build will be rooted in the project's root,
34+
essentially calling this docker build command:
4335

44-
To keep workflow as close to local development as possible, we give
45-
the container the host network. That means if your webserver within Sail binds
46-
to `:8080`, `127.0.0.1:8080` on the host will work just fine.
36+
```bash
37+
docker build --network=host -f $project_root/<org>/<repo>/.sail/Dockerfile $project_root/<org>/<repo>
38+
```
4739

40+
## Container Permissions
4841

49-
## Dockerfile Best Practices
42+
The current user on the host is mapped to the user named `user` within
43+
the development environment. That means files permissioned to `user` within
44+
the container, will appear to have the same set of permissions for your user on the host.
5045

51-
[Official Dockerfile best practices.](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/)
5246

53-
---
47+
Sail uses `user` and not `root` within the container because:
5448

55-
Maximize layer caching by seperating command as much as possible:
49+
- A lot of tools will complain about being root.
50+
- Most developers are used to being non-root and the `sudo` workflow.
5651

57-
**Bad**
58-
```
59-
RUN sudo apt install -y htop dstat dog
60-
```
52+
## Container Naming
6153

62-
**Good**
63-
```
64-
RUN sudo apt install -y htop
65-
RUN sudo apt install -y dstat
66-
RUN sudo apt install -y dog
67-
```
54+
Containers are named `<org>_<project>` in Docker, but `<org>/project` in Sail.
6855

69-
As you become aware of what installations the project _always_ needs, we're
70-
better off merging the commands and moving them to the beginning of the Dockerfile.
56+
## Networking
7157

72-
**Tip**: whenever changing or adding a command, always do it at the bottom of
73-
the Dockerfile. The Dockerfile will approach it's layer-optimized version.
58+
To keep workflow as close to local development as possible, sail uses docker
59+
host networking. That means if your webserver within Sail binds
60+
to `:8080`, it will be accessible from `127.0.0.1:8080` in your browser.
7461

62+
## Dockerfile Best Practices
7563

76-
---
64+
[Dockerfile best practices](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/)
65+
for a reference on how to properly structure and write your [project](/docs/concepts/projects) and [hat](/docs/concepts/hats)
66+
Dockerfiles.

site/content/docs/concepts/hats.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,31 @@
22
type="docs"
33
title="Hats"
44
browser_title="Sail - Docs - Hats"
5+
section_order=3
56
+++
67

7-
A _hat_ is a build directory with a Dockerfile which has it's `FROM` clause
8-
replaced with the repository-provided image. Essentially, hats let you
9-
personalize your development environment.
8+
A _hat_ is a build directory with a Dockerfile that allows you to extend
9+
every project environment with your own personalization. Hats allow you to
10+
bring your own tooling, configuration, and workflow into every Sail project
11+
you work on.
12+
13+
In order for Sail to extend the project's environment, the hat Dockerfile's
14+
`FROM` clause is replaced with the repository-provided image.
1015

1116
For example:
1217

1318
```Dockerfile
14-
FROM ubuntu-dev
19+
FROM ubuntu
20+
1521
RUN sudo apt install fish
1622
RUN chsh user -s $(which fish)
1723
```
1824

1925
is a hat that would install fish, and configure it as the default
2026
shell regardless of which shell the repository-provided image uses.
2127

22-
The `FROM ubuntu-dev` will be replaced with `FROM <repo_image>` when sail
23-
assembles your dev container.
28+
The `FROM ubuntu` will be replaced with `FROM <repo_image>` when sail
29+
assembles your dev container in order to extend the project's environment.
2430

2531
---
2632

@@ -37,4 +43,4 @@ To enable expirementation, hats can be used from github like so:
3743

3844
---
3945

40-
Hats enable personalization, so **GitHub hats should just be used for expirementation.**
46+
Hats enable personalization, so **GitHub hats should just be used for experimentation.**

site/content/docs/concepts/immutability.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

site/content/docs/concepts/labels.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
+++
2+
type="docs"
3+
title="Labels"
4+
browser_title="Sail - Docs - Labels"
5+
section_order=1
6+
+++
7+
8+
Sail makes extensive use of Docker labels to maintain state and to allow users to fully configure
9+
their project environments.
10+
11+
## Configuration Labels
12+
13+
### Project Root Label
14+
15+
As described in [projects](/docs/concepts/projects), the bind mount target of the project's root can be specified
16+
using the `project_root` label. By default the project root is bind mounted to `~/<repo>` inside of
17+
the container.
18+
19+
For example:
20+
21+
```Dockerfile
22+
LABEL project_root "~/go/src/"
23+
```
24+
25+
Will bind mount the host directory `$project_root/<org>/<repo>` to `~/go/src/<repo>` in the container.
26+
27+
28+
### Share Labels
29+
30+
A sail share is a directory on the host that you want shared with your
31+
sail container. Any shares that are specified within the Project or hat
32+
Dockerfiles will be bind mounted to the proper location inside of the
33+
container.
34+
35+
Projects and hats can specify shares using command labels of the form:
36+
37+
`share.<share_name>="host_path:guest_path"`.
38+
39+
For example, if you wanted to share your go mod cache with your container
40+
you would add this to your project or hat Dockerfile:
41+
42+
```Dockerfile
43+
LABEL share.go_mod="~/go/pkg/mod:~/go/pkg/mod"
44+
```
45+
46+
---
47+
48+
Shares are recommended for
49+
50+
- Filesystem-level caches
51+
- Go mod cache
52+
- Yarn cache
53+
- User-specific configuration
54+
- VS Code configuration (auto)
55+
- SSH keys
56+
- gitconfig
57+
- Working data
58+
- Project files (auto)
59+
- Data analysis results
60+
61+
It's important to keep in mind that shares can easily undermine the
62+
reproducibility and consistency of your environments. Be careful with blanket shares
63+
such as `~:~` which introduce variance.
64+
65+
## State Labels
66+
67+
Sail uses Docker labels that begin with `com.coder.sail` to manage any state
68+
that the CLI may need. These labels are only required by the Sail CLI and aren't
69+
useful for user configuration.

0 commit comments

Comments
 (0)