Skip to content
gohacks.dev
DevOps

Dockerfile Generator

Generate a multi-stage production Dockerfile for Node.js, Next.js, PHP-FPM (Laravel), Python with uv, Go or a static site, running as a non-root user.

Free · No sign-up · Your inputs stay in your browser

Input

Generate a production Dockerfile

Output

Dockerfile

333 characters

.dockerignore (minimum)

node_modules .git .env *.log vendor .next dist __pycache__ .venv

Multi-stage: build tools stay in the first stage and only the runtime ships. Dependency manifests are copied before the source so a code change does not reinstall every package, and the cache mounts need BuildKit, which docker build uses by default since Docker 23.

Runs in this browser. Nothing you paste is sent to a server.

Why multi-stage

Compilers, dev dependencies and build caches stay in the first stage; only the runtime and the built application ship. A Go service ends up as one binary on a distroless base of a few megabytes, and a Next.js app ships its standalone output instead of all of node_modules. The Docker build best practices page explains the layer ordering.

Cache mounts

RUN --mount=type=cache keeps npm, Composer, uv and Go caches between builds without baking them into a layer. It needs BuildKit, the default builder since Docker Engine 23. Pin base images to a version, and to a digest for reproducible builds.

Share

Frequently asked questions

Why copy package.json before the rest of the source?
Docker caches each layer. Copying the dependency manifests first means a code change reuses the layer with installed dependencies instead of reinstalling them on every build.
Why run as a non-root user?
A process that escapes the application runs with the container's user. As root it can do more damage inside the container and, with some misconfigurations, on the host.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools