Skip to main content
CalcChef

Dockerfile Generator

Generate a Dockerfile from a form: pick a language, base image, ports, env vars, build and start commands, then copy or download the file. How it works

Use the Dockerfile Generator

Listening ports
3000
Environment variables (ENV)
Build-time variables (ARG)
Dockerfile · node
1# syntax=docker/dockerfile:1.72# Generated by CalcChef Dockerfile Generator — YYYY-MM-DD3# Tip: add a .dockerignore with at least: node_modules, .git, .env, dist, build, target, __pycache__4 5FROM node:24-alpine6WORKDIR /app7 8COPY package*.json ./9RUN npm ci10 11COPY . .12RUN npm run build13 14# Run as non-root15RUN addgroup -S app && adduser -S app -G app -u 1001 \16 && chown -R app:app /app17USER app18 19# Listening ports20EXPOSE 300021 22CMD ["node", "server.js"]

Estimated size: ≈ 50–180 MB (alpine)

About the Dockerfile Generator

The default settings give a Dockerfile for a Node.js app that starts with # syntax=docker/dockerfile:1.7, then FROM node:24-alpine, WORKDIR /app, COPY package*.json ./, RUN npm ci, COPY . ., RUN npm run build, a non-root user, EXPOSE 3000 and a CMD that runs node server.js. Node.js 24 is the long-term-support line that endoflife.date listed on 16 October 2026, with security fixes until 30 April 2028. Check the tag against that list again before you build, because support dates move on. The file is text only: nothing has been built or checked against Docker.

What each language preset starts with

LanguageBase imageInstall commandPortMulti-stage by default
Node.jsnode:24-alpinenpm ci3000no
Pythonpython:3.12-slimpip install --no-cache-dir -r requirements.txt5000no
Gogolang:1.27-alpinego mod download8080yes
Javaeclipse-temurin:21-jre-alpinemvn -B -e -DskipTests dependency:go-offline8080yes
.NETmcr.microsoft.com/dotnet/aspnet:10.0dotnet restore8080yes
Rubyruby:3.3-alpinebundle install --jobs 4 --retry 34567no
PHPphp:8.3-cli-alpinecomposer install --no-dev --no-scripts --prefer-dist8000no
Rustrust:1-slimnone8080yes
Static HTMLnginx:1.30-alpinenone80no

Read from the generator's own language defaults. They are starting values for you to change, not recommendations, and the tags were checked on 16 October 2026 against endoflife.date and nginx.org: Node.js 24 (long-term support), Go 1.27, .NET 10 (long-term support) and nginx 1.30 (the stable line). Python 3.12, Ruby 3.3, PHP 8.3 and Java 21 were still supported and are unchanged. The start commands assume a layout: Python runs app.py, Ruby runs app.rb on Sinatra's port 4567, and PHP runs php artisan serve, which only exists in a Laravel project. Java builds in a Maven image (with multi-stage off, that image is the only stage), and the build copies the first jar in target/ that is not a sources, javadoc or tests jar to app.jar. Rust has no install step, because cargo needs the source as well as Cargo.toml, and its build copies target/release/app, so the binary must be named app. PHP copies the Composer binary and installs unzip, installs without running scripts before the source is copied, and dumps the optimized autoloader after it. Its start command listens on 0.0.0.0, because artisan serve listens only inside the container by default.

How to use this tool

  1. Pick a project preset or a language, then a base image from the list or your own image:tag. Check that the tag is still supported: the defaults were checked on 16 October 2026.
  2. Set the working directory, ports, environment variables, build arguments, and the install, build and start commands.
  3. Choose multi-stage and a non-root user if you want them. Read any warning above the file.
  4. Press Copy or Download, then build the image yourself to check it.

Frequently asked questions

How do I write a Dockerfile for a Node.js app?
Copy package.json and the lock file first and run npm ci, so Docker can reuse that layer when only source files change. Then copy the rest, run the build, set a non-root user, EXPOSE the port and start the app with CMD. The generator writes those lines in that order for Node.js, starting from FROM node:24-alpine; change the tag if your app targets another supported Node.js line.
Why is the syntax line the first line?
Docker reads a parser directive such as # syntax=docker/dockerfile:1.7 only at the top of the file. Once a comment, a blank line or an instruction has been read, a later directive is treated as an ordinary comment, so the generator puts it first.
How does it write environment variables with spaces or a dollar sign?
A value with a space, a quote or a backslash is wrapped in double quotes, so my value becomes ENV APP_MODE="my value". A dollar sign is escaped, because Docker expands $name in ENV values, so the text $5 stays $5. One variable is one line, and several use continuation lines with no continuation after the last.
What is the difference between the exec and shell form of CMD?
A start command written as a JSON array, such as ["node", "server.js"], becomes the exec form and runs the program directly. Any other text becomes the shell form, which the generator wraps in /bin/sh -c on Alpine images and bash -c on others. Docker recommends the exec form, because the shell form does not pass signals such as SIGTERM to the program.
Does the Dockerfile run as root?
By default it adds a user called app with UID 1001 and switches to it, for every language except static HTML. The nginx image starts as root and binds port 80, so non-root is off for it by default and can still be ticked. A user name keeps only letters, digits, dot, dash and underscore.
Does the page check that the Dockerfile builds?
No. It writes the file from your form and removes line breaks and control characters from every value, with a warning that lists what it removed. It does not run Docker, so build the image and read the output before you rely on the file.

Related Tools

View all tools