diff --git a/manifest.json b/manifest.json index 9e53536de..c75b984a5 100644 --- a/manifest.json +++ b/manifest.json @@ -53,9 +53,6 @@ { "path": "./workspaces/lifecycle.md" }, - { - "path": "./workspaces/applications.md" - }, { "path": "./workspaces/autostart.md" }, @@ -86,6 +83,9 @@ { "path": "./workspaces/vs-code-extensions.md" }, + { + "path": "./workspaces/applications.md" + }, { "path": "./workspaces/workspace-params.md" }, diff --git a/workspaces/applications.md b/workspaces/applications.md index c4dc2aa7e..3bceab6f0 100644 --- a/workspaces/applications.md +++ b/workspaces/applications.md @@ -1,31 +1,32 @@ --- -title: "Applications" +title: "Workspace applications" description: Learn how to access web apps running in your workspace. state: beta --- -You can connect to web applications installed on your workspace using the +You can connect to web applications installed on your workspace using an applications specification file located at `/coder/apps/config.yaml` of the workspace filesystem. ![Application Launcher](../assets/workspaces/applications.png) -## Enabling custom apps +## Enabling workspace applications -If you'd like to use custom apps in Coder, you can enable this feature in the -UI: +If you'd like to use workspace applications in Coder, you can enable this +feature in the UI: 1. In the top-right, click on your avatar and select **Feature Preview**. 1. Click **Workspace applications** and select **Enable**. ## Application specification file -To define custom applications, add a configuration file at +To define workspace applications, add a configuration file at `/coder/apps/config.yaml` to your image. -The config file specifies the parameters Coder requires in order to launch the -application. Within the file, you can specify the following for each -application: +The config file specifies the parameters Coder requires to launch the +application. Here is a sample `config.yaml` for adding a Python HTTP server as a +workspace application. Note that this requires the `python3` binary, which is +included in Coder's base images. ```yaml # /coder/apps/config.yaml @@ -34,11 +35,11 @@ apps: # Name of application in launcher. Name may consist of alphanumeric # characters, dashes, underscores. Names must begin with an alphanumeric # character. Names must be unique per application. Required. - - name: projector + - name: HTTP server # Application scheme - must be http or https. Required. scheme: http # Application port. Required. - port: 9999 + port: 8000 # Host of the application to use when dialing. Defaults to localhost. # Optional. host: "localhost" @@ -46,11 +47,11 @@ apps: working-directory: /home/coder # File path to icon used in application launcher. Icons should be either # PNG, SVG, or JPG. Required. - icon-path: /home/coder/goland.svg + icon-path: /home/coder/python-logo.png # Command to start the application. Required. - command: /home/coder/.local/bin/projector + command: python3 # Array of arguments for command. Optional. - args: ["run"] + args: ["-m", "http.server"] # Health checks to get running application status. Can use exec or http # health checks to localhost. Optional, but we recommend specifying a # health check. If you don't supply one, then an http request is sent to @@ -59,7 +60,7 @@ apps: # Exec commands require an exit code of '0' to report healthy. exec: command: "pgrep" - args: ["projector"] + args: ["python3"] # http sends a GET request to the address specified via the parameters. # Expects the status codes to match; default is HTTP 200. http: @@ -71,10 +72,10 @@ apps: host: "localhost" # Port to use when dialing the application. If not specified it # inherits the application port. Optional. - port: 9999 + port: 8000 # Path to use for the health check. If not specified defaults to # "/". Optional. - path: "/healthz" + path: "" ``` **Notes**: @@ -82,6 +83,21 @@ apps: - A health check _must_ report healthy for you to access the application. - If you specify both the HTTP and Exec health checks, Coder prioritizes HTTP. +### Image creation + +When creating your image, be sure to: + +1. In the folder where your Dockerfile is, add a `coder/apps` folder +1. Add the `config.yaml` you created to `coder/apps`. +1. Add the icon that you would like Coder to render for your app to the + `coder/apps` folder +1. Add a step to your Dockerfile to copy the `coder` folder into the image: + +```text +# copy custom apps info (config.yaml) +COPY ["./coder", "/coder"] +``` + ## Sample usage Coder offers an [image](https://hub.docker.com/r/codercom/enterprise-vnc) that @@ -89,6 +105,11 @@ helps you [set up a VNC](../guides/customization/vnc.md). With a VNC available, you can add an icon to your **Browser applications** via setting the [config file](https://github.com/coder/enterprise-images/blob/91ef8f521b2275783fed54b27052cc544153cd99/images/vnc/coder/apps/config.yaml). +You are welcome to try the +[public Dockerfile repo that contains the example above](https://github.com/mtm20176/dockerfiles/tree/main/python/workspace-apps). +The repo includes config files that set up Python and Node.js HTTP servers and +the accompanying icons. + You can also see our [blog post](https://coder.com/blog/run-any-application-or-ide-in-coder) for further samples on adding tools like Portainer, Insomnia, and various versions