anomalyco/sst · critical

default Python Dockerfile not found at %s: %w

Error message

default Python Dockerfile not found at %s: %w

What it means

The Python runtime in SST expects a default Dockerfile (python.Dockerfile) shipped inside the platform directory. During `ensureDockerfile`, when the project has no custom Dockerfile, it copies the bundled default into the build context. If `os.Stat` on the bundled file fails (missing or unreadable), this error wraps that stat error.

Source

Thrown at pkg/runtime/python/build.go:222

	customDockerfile := filepath.Join(projectRoot, "Dockerfile")
	if _, err := os.Stat(customDockerfile); err == nil {
		return copyFile(customDockerfile, outputDockerfile)
	}

	if projectInfo.PyprojectPath != "" {
		handlerPkgDir := filepath.Dir(projectInfo.PyprojectPath)
		if handlerPkgDir != projectRoot {
			handlerDockerfile := filepath.Join(handlerPkgDir, "Dockerfile")
			if _, err := os.Stat(handlerDockerfile); err == nil {
				return copyFile(handlerDockerfile, outputDockerfile)
			}
		}
	}

	defaultDockerfile := filepath.Join(path.ResolvePlatformDir(input.CfgPath), "dist", "dockerfiles", "python.Dockerfile")
	if _, err := os.Stat(defaultDockerfile); err != nil {
		return fmt.Errorf("default Python Dockerfile not found at %s: %w", defaultDockerfile, err)
	}

	return copyFile(defaultDockerfile, outputDockerfile)
}

// adjustHandlerPath adjusts the handler path for the artifact structure.
// Strips workspace prefixes for containers and flattens src/ layouts.
func adjustHandlerPath(input *runtime.BuildInput, projectInfo *projectInfo) (string, error) {
	handler := strings.TrimPrefix(input.Handler, "./")

	// For container builds, strip the workspace prefix since source files
	// are copied to the root of the build context.
	if input.IsContainer && projectInfo.ProjectRoot != "" && projectInfo.PyprojectPath != "" {
		workspaceDir := filepath.Dir(projectInfo.PyprojectPath)
		if workspaceDir != projectInfo.ProjectRoot {
			relWorkspacePath, err := filepath.Rel(projectInfo.ProjectRoot, workspaceDir)
			if err == nil && relWorkspacePath != "." {
				prefix := filepath.ToSlash(relWorkspacePath) + "/"

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Run `bun run setup` (or `bun run build:platform`) in the sst repo so `platform/dist/dockerfiles/python.Dockerfile` is generated
  2. Reinstall the sst package/CLI so bundled dist assets are restored
  3. Verify the file exists: `ls platform/dist/dockerfiles/python.Dockerfile` and check permissions
  4. If using a custom platform path via config, confirm `path.ResolvePlatformDir(cfgPath)` points at the real platform dir

Example fix

// before: running `go run ./cmd/sst deploy` from a fresh clone without platform assets
// after:
bun run build:platform
cd examples/my-app && go run ../../cmd/sst deploy
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from "fs";
import * as path from "path";
const df = path.resolve("platform/dist/dockerfiles/python.Dockerfile");
if (!existsSync(df)) throw new Error(`Run 'bun run build:platform' — missing ${df}`);

Type guard

const hasDefaultDockerfile = (platformDir: string) =>
  existsSync(path.join(platformDir, "dist", "dockerfiles", "python.Dockerfile"));

Prevention

When it happens

Trigger: Running `sst deploy`/`sst build` for a `sst.aws.Function` with runtime `python3.x` when the platform dir was not fully built (e.g. `bun run build:platform` skipped) or was partially copied, so `platform/dist/dockerfiles/python.Dockerfile` does not exist.

Common situations: Cloning the repo and running the CLI without building the platform; a stale or truncated npm/pypi install of sst where dist assets were pruned; running the CLI binary from the wrong working directory so `path.ResolvePlatformDir` resolves to a location without dist assets; antivirus or cleanup tooling deleting files under `dist/`.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/f34df4d3bff0c051. Report an issue: GitHub.