@@ -13,44 +13,127 @@ type LoggerFunc func(level codersdk.LogLevel, format string, args ...interface{}
1313
1414// Options contains the configuration for the envbuilder.
1515type Options struct {
16- SetupScript string
17- InitScript string
18- InitCommand string
19- InitArgs string
20- CacheRepo string
21- BaseImageCacheDir string
22- LayerCacheDir string
23- DevcontainerDir string
16+ // SetupScript is the script to run before the init script. It runs as the
17+ // root user regardless of the user specified in the devcontainer.json file.
18+ // SetupScript is ran as the root user prior to the init script. It is used to
19+ // configure envbuilder dynamically during the runtime. e.g. specifying
20+ // whether to start systemd or tiny init for PID 1.
21+ SetupScript string
22+ // InitScript is the script to run to initialize the workspace.
23+ InitScript string
24+ // InitCommand is the command to run to initialize the workspace.
25+ InitCommand string
26+ // InitArgs are the arguments to pass to the init command. They are split
27+ // according to /bin/sh rules with https://github.com/kballard/go-shellquote.
28+ InitArgs string
29+ // CacheRepo is the name of the container registry to push the cache image to.
30+ // If this is empty, the cache will not be pushed.
31+ CacheRepo string
32+ // BaseImageCacheDir is the path to a directory where the base image can be
33+ // found. This should be a read-only directory solely mounted for the purpose
34+ // of caching the base image.
35+ BaseImageCacheDir string
36+ // LayerCacheDir is the path to a directory where built layers will be stored.
37+ // This spawns an in-memory registry to serve the layers from.
38+ LayerCacheDir string
39+ // DevcontainerDir is the path to the folder containing the devcontainer.json
40+ // file that will be used to build the workspace and can either be an absolute
41+ // path or a path relative to the workspace folder. If not provided, defaults
42+ // to `.devcontainer`.
43+ DevcontainerDir string
44+ // DevcontainerJSONPath is a path to a devcontainer.json file
45+ // that is either an absolute path or a path relative to
46+ // DevcontainerDir. This can be used in cases where one wants
47+ // to substitute an edited devcontainer.json file for the one
48+ // that exists in the repo.
49+ // If neither `DevcontainerDir` nor `DevcontainerJSONPath` is provided,
50+ // envbuilder will browse following directories to locate it:
51+ // 1. `.devcontainer/devcontainer.json`
52+ // 2. `.devcontainer.json`
53+ // 3. `.devcontainer/<folder>/devcontainer.json`
2454 DevcontainerJSONPath string
25- DockerfilePath string
26- BuildContextPath string
27- CacheTTLDays int64
28- DockerConfigBase64 string
29- FallbackImage string
30- ExitOnBuildFailure bool
31- ForceSafe bool
32- Insecure bool
33- IgnorePaths []string
34- SkipRebuild bool
35- GitURL string
36- GitCloneDepth int64
55+ // DockerfilePath is the relative path to the Dockerfile that will be used to
56+ // build the workspace. This is an alternative to using a devcontainer that
57+ // some might find simpler.
58+ DockerfilePath string
59+ // BuildContextPath can be specified when a DockerfilePath is specified
60+ // outside the base WorkspaceFolder. This path MUST be relative to the
61+ // WorkspaceFolder path into which the repo is cloned.
62+ BuildContextPath string
63+ // CacheTTLDays is the number of days to use cached layers before expiring
64+ // them. Defaults to 7 days.
65+ CacheTTLDays int64
66+ // DockerConfigBase64 is the base64 encoded Docker config file that will be
67+ // used to pull images from private container registries.
68+ DockerConfigBase64 string
69+ // FallbackImage specifies an alternative image to use when neither an image
70+ // is declared in the devcontainer.json file nor a Dockerfile is present. If
71+ // there's a build failure (from a faulty Dockerfile) or a misconfiguration,
72+ // this image will be the substitute. Set ExitOnBuildFailure to true to halt
73+ // the container if the build faces an issue.
74+ FallbackImage string
75+ // ExitOnBuildFailure terminates the container upon a build failure. This is
76+ // handy when preferring the FALLBACK_IMAGE in cases where no
77+ // devcontainer.json or image is provided. However, it ensures that the
78+ // container stops if the build process encounters an error.
79+ ExitOnBuildFailure bool
80+ // ForceSafe ignores any filesystem safety checks. This could cause serious
81+ // harm to your system! This is used in cases where bypass is needed to
82+ // unblock customers.
83+ ForceSafe bool
84+ // Insecure bypasses TLS verification when cloning and pulling from container
85+ // registries.
86+ Insecure bool
87+ // IgnorePaths is the comma separated list of paths to ignore when building
88+ // the workspace.
89+ IgnorePaths []string
90+ // SkipRebuild skips building if the MagicFile exists. This is used to skip
91+ // building when a container is restarting. e.g. docker stop -> docker start
92+ // This value can always be set to true - even if the container is being
93+ // started for the first time.
94+ SkipRebuild bool
95+ // GitURL is the URL of the Git repository to clone. This is optional.
96+ GitURL string
97+ // GitCloneDepth is the depth to use when cloning the Git repository.
98+ GitCloneDepth int64
99+ // GitCloneSingleBranch clone only a single branch of the Git repository.
37100 GitCloneSingleBranch bool
38- GitUsername string
39- GitPassword string
40- GitHTTPProxyURL string
41- WorkspaceFolder string
42- SSLCertBase64 string
43- ExportEnvFile string
44- PostStartScriptPath string
101+ // GitUsername is the username to use for Git authentication. This is
102+ // optional.
103+ GitUsername string
104+ // GitPassword is the password to use for Git authentication. This is
105+ // optional.
106+ GitPassword string
107+ // GitHTTPProxyURL is the URL for the HTTP proxy. This is optional.
108+ GitHTTPProxyURL string
109+ // WorkspaceFolder is the path to the workspace folder that will be built.
110+ // This is optional.
111+ WorkspaceFolder string
112+ // SSLCertBase64 is the content of an SSL cert file. This is useful for
113+ // self-signed certificates.
114+ SSLCertBase64 string
115+ // ExportEnvFile is the optional file path to a .env file where envbuilder
116+ // will dump environment variables from devcontainer.json and the built
117+ // container image.
118+ ExportEnvFile string
119+ // PostStartScriptPath is the path to a script that will be created by
120+ // envbuilder based on the postStartCommand in devcontainer.json, if any is
121+ // specified (otherwise the script is not created). If this is set, the
122+ // specified InitCommand should check for the presence of this script and
123+ // execute it after successful startup.
124+ PostStartScriptPath string
45125 // Logger is the logger to use for all operations.
46126 Logger LoggerFunc
47- // Filesystem is the filesystem to use for all operations.
48- // Defaults to the host filesystem.
127+ // Filesystem is the filesystem to use for all operations. Defaults to the
128+ // host filesystem.
49129 Filesystem billy.Filesystem
50- // These options are specifically used when envbuilder
51- // is invoked as part of a Coder workspace.
52- CoderAgentURL * url.URL
53- CoderAgentToken string
130+ // These options are specifically used when envbuilder is invoked as part of a
131+ // Coder workspace.
132+ CoderAgentURL * url.URL
133+ // CoderAgentToken is the authentication token for a Coder agent.
134+ CoderAgentToken string
135+ // CoderAgentSubsystem is the Coder agent subsystems to report when forwarding
136+ // logs. The envbuilder subsystem is always included.
54137 CoderAgentSubsystem []string
55138}
56139
0 commit comments