All jobs

Write a Dockerfile for a Bolt for JavaScript Slack App

Yes. An agent writes a non-root Dockerfile for your Socket Mode Bolt app, shows the image starts and reaches Slack's auth step, adds a CI build, and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent starts by reading how the app connects, because that decides whether the container needs a port at all. In a project like slack-samples/bolt-js-getting-started-app, app.js creates an App with socketMode: true, a bot token and an app-level token from the environment, listens for messages containing hello, answers with a Block Kit section and a button, handles button_click, and calls app.start(process.env.PORT || 3000). In Socket Mode that start opens an outbound WebSocket to Slack and the port is never bound for events, which manifest.json confirms with socket_mode_enabled set and no request URL. package.json is an ES module with one dependency, @slack/bolt, pinned to 5.1.0 in a version 3 package-lock.json, and npm start runs node app.js. AGENTS.md asks for no code comments, and .gitignore lists only node_modules/.

The Dockerfile is deliberately short. It starts from the Node LTS Alpine image, copies package.json and package-lock.json first and runs npm ci --omit=dev so the dependency layer is cached until the lockfile changes, then copies app.js. It sets NODE_ENV=production, switches to the node user the image already has, adds tini so the process receives SIGTERM as PID 1 and the WebSocket closes cleanly on docker stop, and ends with CMD ["node", "app.js"]. There is no EXPOSE and no HEALTHCHECK, and the pull request says why: nothing listens, so there is nothing to probe over HTTP. Following AGENTS.md, the file carries no comments; the reasoning is in the pull request description instead. A .dockerignore keeps node_modules, .git and any .env out of the build context, so a local token file cannot end up in a layer.

Tokens are the part that must not be in the image. The Dockerfile sets no SLACK_BOT_TOKEN or SLACK_APP_TOKEN; the run command passes them with -e or an env file at start, the same two variables README.md tells a developer to export. The agent adds that run line to the README's running section beneath the npm run start step.

The sandbox has no Docker, so the agent installs docker.io, starts dockerd, builds the image and runs it. Without real tokens the app cannot finish starting, and the agent uses that honestly: it runs the container with placeholder tokens and shows that Node loads app.js, Bolt constructs the Socket Mode receiver and the start fails at Slack's apps.connections.open call with an authentication error, which is the last step that can be checked without a workspace. It then adds a job to a new .github/workflows/ci.yml that builds the image on every pull request with docker build, so a broken Dockerfile fails a pull request and not a deploy. The existing dependencies.yml workflow, which approves and merges Dependabot updates, is untouched.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Write a Dockerfile for this Bolt for JavaScript app. Read package.json, package-lock.json, app.js, manifest.json, README.md, AGENTS.md, .gitignore and the workflows under .github first. The app uses Socket Mode, so do not expose a port or add an HTTP health check; explain that in the pull request. Start from the Node LTS Alpine image, copy the package files and run npm ci --omit=dev before copying app.js so the dependency layer caches, set NODE_ENV=production, run as the node user, use tini as the entrypoint so SIGTERM reaches node, and end with CMD node app.js. Do not put any Slack token in the image; document passing SLACK_BOT_TOKEN and SLACK_APP_TOKEN at docker run in the README. Add a .dockerignore for node_modules, .git and .env files. Keep the Dockerfile free of comments as AGENTS.md asks. Docker is not installed here: install docker.io, start dockerd, build the image, run it with placeholder tokens and show that it reaches Slack's authentication step before failing. Add a GitHub Actions workflow that builds the image on pull requests, then open a pull request that names the base image and says why there is no EXPOSE.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

What comes back is a pull request that adds Dockerfile, .dockerignore and .github/workflows/ci.yml, and adds a run section to README.md. The description names the base image tag, shows the docker build output with its layer order, and shows the container log from the placeholder run ending at Slack's authentication error, so a reviewer can see that the image is correct up to the point where only real tokens remain.

The run's record holds the Docker install, the build, the container run and the workflow file, so every line of the description points at a command the run executed.

Before merging, a reviewer decides whether to pin the Node image to a digest, whether to publish the image from the same workflow, and whether the deploy target wants an HTTP endpoint anyway, in which case Bolt's customRoutes or a move off Socket Mode is a separate change. The app code is unchanged.

Run it on every Slack app without an image

A team with several Bolt apps starts one run per repository from its own server: one POST /o/{org}/sessions each, with that repository in resources and a request_id that is a UUID v5 of the repository's full name, so a retried call returns the run already started instead of a second pull request. Each run reads its own app.js to see whether it is Socket Mode or HTTP, and writes the image that app needs.

To keep the image buildable, an automation on the Project with a github trigger on pull_request.opened and pull_request.synchronize and the prompt "if this pull request changes package.json, package-lock.json or the Dockerfile, build the image and comment with the result" reads each pull request. The trigger puts the pull request after the prompt; only work by an owner, member or collaborator fires it, never a fork's.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

A Dockerfile for a Slack app is usually copied from an HTTP service, which is how a Socket Mode app ends up with an EXPOSE, a health check that can never pass and a token baked into a layer. The agent reads the mode from app.js and manifest.json, builds the image in its own sandbox with Docker installed for that run alone, and runs it far enough to show where real credentials take over.

Every command stays with the run, from the Docker install to the container log, and the pull request cites them. Doing the same for each Slack app a team owns costs no more attention than one, because each run has its own machine and its own record.

Frequently asked questions

Why no EXPOSE or HEALTHCHECK?

Because in Socket Mode the app connects out to Slack over a WebSocket and never binds the port it passes to app.start. An EXPOSE would document a port nothing listens on, and an HTTP health check would fail forever. A reviewer who wants a liveness signal can add a Bolt customRoutes endpoint, which is a code change the agent leaves out of this pull request.

Why tini?

As PID 1, Node does not get default signal handling, so docker stop waits out its timeout and kills the process, and the Socket Mode connection drops without a close frame. tini forwards SIGTERM to Node so Bolt can shut the receiver down. The alternative is docker run --init, which depends on whoever runs the container remembering it.

How can the run prove the image works without a workspace?

It cannot prove the whole path, and the pull request says so. What it shows is the container starting, Node loading app.js, Bolt building its receiver and the start failing at Slack's authentication call with placeholder tokens. That is every step the image controls; the next step needs a real SLACK_APP_TOKEN, which belongs in the deploy environment and not in a pull request.

Why npm ci --omit=dev and not npm install?

npm ci installs exactly what the version 3 lockfile says and fails if package.json disagrees, so the image is reproducible from the commit. --omit=dev skips development packages, and here there are none today, so the flag costs nothing and prevents a future test runner from landing in production layers.

More Bolt for JavaScript jobs

The same job on other stacks

Keep reading