# Prompting For A Dockerfile That Is Not 1.2GB

> Name the constraints — multi-stage, non-root, pinned — or you get the naive one.

- **Author:** [Erik Lindqvist (@erik_lindqvist)](https://www.promptabide.com/erik_lindqvist)
- **Published:** 2026-02-15
- **Updated:** 2026-08-22
- **Tags:** `devops`, `docker`, `containers`
- **Views:** 7330
- **Likes:** 264

## Prompt

```
The default generated Dockerfile is `FROM node:latest`, copy everything, npm install, done. It works and it is 1.2GB and it runs as root.

The constraint list that fixes it:

"Write a Dockerfile for a TypeScript Node service.
- Multi-stage: build stage compiles, runtime stage carries only dist + production deps
- Pin the base image by digest, not by tag
- Run as a non-root user; do not create it as UID 1000 if the base already has one
- Copy package files and install before copying source, so the layer caches
- No secrets in build args
- HEALTHCHECK that hits the real readiness endpoint
- .dockerignore covering node_modules, .git, .env, tests"

Same service, 180MB, non-root, and the dependency layer actually caches between builds.

The digest pinning is the one people push back on. Tags move. If you cannot reproduce a build from six months ago, that is why.
```

---

Canonical HTML: https://www.promptabide.com/bides/dockerfile-not-1gb-erik-lindqvist-1
Agent guide: https://www.promptabide.com/llms.txt · https://www.promptabide.com/agent-instructions.md
Sitemap: https://www.promptabide.com/sitemap.xml
