Add `nx add docker` to write the container files

Open
#683 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
54/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, node.js, python, vite

Research direction

Start with the Docker section in docs/deployment/README.md and the file-writing behavior of nx add vercel from issue #671. Trace the CLI entry points for nx add and nexy add, then check how generated files are tested. Done means the Docker files match the documented commands, preserve developer-owned files, are idempotent, and the docs are listed in docs/README.md and llms.txt.

Written by the indexing model from the issue text.

Description

enhancement

Problem

The deployment docs show a working multi-stage Dockerfile, but a developer has to copy it into each project and keep it in sync with the documented build and start commands. A hand-copied file can expose Node in the runtime image, omit .dockerignore, or use the wrong command.

Proposed solution

Add nx add docker (also available as nexy add docker) that writes the container files for an existing Nexy project:

  • Write a Dockerfile matching docs/deployment/README.md: a Node build stage with uv sync --frozen and uv run nx build, and a Python runtime stage that serves with nx start --host 0.0.0.0 --port 8000.
  • Write a .dockerignore that keeps local virtualenvs, caches, git data and __nexy__/ out of the build context.
  • Keep the action secret out of the image and document NEXY_ACTION_SECRET as a runtime environment variable.
  • Print every file changed, skip files that already have the wanted content, and leave the project unchanged on a second run, like nx add vercel.

Acceptance criteria:

  • docker build followed by docker run -p 8000:8000 serves the built app.
  • The runtime stage needs Python only; Node and Vite are not present in the final image.
  • Running the command twice produces no further changes and never overwrites a file the developer owns.
  • Tests cover the generated bytes, the ignore list, conflict handling and idempotency.
  • A docs page explains build, run, environment variables and health checks, and is listed in docs/README.md and llms.txt.

Alternative solutions

Keep the Dockerfile only in docs/deployment/README.md. That avoids a new command but leaves copying and drift to every project.

Additional context

The verified source is the Docker section of docs/deployment/README.md. The command should follow the file writing behavior of nx add vercel (issue #671): data describing the generated files, no platform dependency added to the framework core, and no overwrite of a file the developer owns.

Validation

  • I have searched existing issues and this is not a duplicate.
  • I would be willing to help implement this feature.
Dominant language
Python
Stars
11
Forks
6
Avg merge
2h 14m
Merged PRs (30d)
265

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NexyPy/nexy

All issues in NexyPy/nexy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.