Skip to content

feat: add nextjs-app example template#74

Open
ItamarZand88 wants to merge 1 commit into
mainfrom
itamar/alien-40-example-project-nextjs-app
Open

feat: add nextjs-app example template#74
ItamarZand88 wants to merge 1 commit into
mainfrom
itamar/alien-40-example-project-nextjs-app

Conversation

@ItamarZand88

Copy link
Copy Markdown
Contributor

Summary

Adds a nextjs-app example: the smallest containerized Next.js app — one container, one page, one health route — available through alien init and deployable to AWS, GCP, and Azure.

Step-by-step flow when a user starts from this template:

  1. alien init nextjs-app scaffolds the example into a new directory.
  2. alien release builds the image from the included Dockerfile — Next.js standalone output, so the runtime image is just server.js and its traced files, no node_modules. ← the heart: a plain web app shipped as a single container
  3. A deployment provisions that container behind an HTTPS load balancer in the customer's account.

This PR changes the examples catalog from worker-style templates only to also covering a standard containerized web app.

What I did

  • New examples/nextjs-app: App Router page + /api/health route, multi-stage Dockerfile, alien.ts with one Container (cpu 0.5, 512Mi, port 3000, exposed over HTTP), pinned to the aws/gcp/azure platforms.
  • Registered the template: examples/README.md table row, pnpm workspace member, and the alien init offline fallback list.
  • Local development uses next dev directly (hot reload); deploys go through alien deploy.

Files touched

  • examples/nextjs-app/** — the example (app code, Dockerfile, alien.ts, README, configs)
  • examples/README.md, examples/pnpm-workspace.yaml — catalog row + workspace member
  • crates/alien-cli/src/commands/init.rs — one entry in the KNOWN_TEMPLATES fallback array

How I tested

  • Manually: pnpm exec next build from the example compiles (/ static, /api/health dynamic). Released with alien release --platforms aws,gcp,azurerel_94NtNCX9Z3Jk2cUjD1lIP8VxRJLF. Deployed that release to a test AWS account through a deployment link (CloudFormation, default-VPC network), waited for running, then curl https://app.17opmt.vpc.direct/api/health returned {"status":"ok"} and the landing page served over HTTPS. Tore the deployment down after.
  • Checks: cargo check -p alien-cli for the template entry; biome check examples/nextjs-app clean.

@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown

Greptile Summary

Adds a nextjs-app example template — a minimal containerized Next.js app (App Router, one page, one health route) that users can scaffold with alien init and deploy to AWS, GCP, or Azure via a multi-stage Dockerfile using Next.js standalone output.

  • New examples/nextjs-app: App Router page + /api/health route, multi-stage Dockerfile, alien.ts with a single Container (0.5 cpu / 512Mi / port 3000), and supporting configs. The standalone output means the runtime image contains only server.js and traced files.
  • Catalog registration: Added to examples/README.md, pnpm-workspace.yaml, and the KNOWN_TEMPLATES fallback in init.rs so alien init nextjs-app works offline.
  • Main concern: package-lock.json is gitignored (consistent with all other templates), so npm install in the Dockerfile build stage runs without a lock file, making each alien release potentially resolve different transitive dependency versions.

Confidence Score: 4/5

Safe to merge; the template is self-contained and the changes to shared files (init.rs, workspace yaml, README) are minimal and low-risk.

The template is well-structured and the standalone output + Dockerfile pattern works as described. The main gap is that Docker builds install dependencies without a lock file on every release, which can drift silently over time. A missing start script is a minor usability omission.

examples/nextjs-app/Dockerfile and examples/nextjs-app/package.json are worth a second look for the lock-file and start-script gaps.

Important Files Changed

Filename Overview
examples/nextjs-app/Dockerfile Multi-stage build using Next.js standalone output; build stage runs npm install without a lock file because package-lock.json is gitignored, making Docker builds non-deterministic.
examples/nextjs-app/alien.ts Defines a single Container with cpu/memory/port/expose/environment matching the Dockerfile; platform list and empty permission profile look correct.
examples/nextjs-app/package.json Dependencies look correct; missing a start script to run the standalone output locally, which leaves a usability gap for local production testing.
examples/nextjs-app/next.config.ts Minimal config with output standalone enabled, which is required for the Dockerfile to produce a self-contained server.js.
crates/alien-cli/src/commands/init.rs One-line addition to KNOWN_TEMPLATES fallback; description is consistent with template.toml and README.
examples/nextjs-app/app/api/health/route.ts Minimal GET handler returning status ok; correct App Router Route Handler syntax.
examples/nextjs-app/.dockerignore Excludes node_modules, .next, and alien-specific files from the Docker build context; looks correct.

Sequence Diagram

sequenceDiagram
    participant User
    participant AlienCLI
    participant Docker
    participant CloudProvider

    User->>AlienCLI: alien init nextjs-app
    AlienCLI-->>User: scaffold files (Dockerfile, alien.ts, app/)

    User->>AlienCLI: alien release
    AlienCLI->>Docker: build (multi-stage)
    Docker->>Docker: Stage 1 – npm install + next build
    Docker->>Docker: Stage 2 – copy .next/standalone + static + public
    Docker-->>AlienCLI: image tagged and pushed

    User->>AlienCLI: alien deploy production --platform aws
    AlienCLI->>CloudProvider: provision Container + HTTPS load balancer
    CloudProvider-->>User: public URL (HTTPS)

    User->>CloudProvider: GET /api/health
    CloudProvider-->>User: "{status: ok}"
Loading
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
examples/nextjs-app/Dockerfile:3-4
**Non-deterministic dependency installs in Docker build**

`package-lock.json` is listed in the template's `.gitignore`, so the file is never committed and therefore never present when `alien release` builds this image. `COPY package-lock.json* ./` silently copies nothing, and `npm install` then resolves semver ranges at build time, meaning successive `alien release` runs can produce images with different transitive dependency versions. Every other Node.js template in this repo has the same gitignore entry, but here it is the primary production build path. Consider generating and committing a `package-lock.json` for the example (removing it from the example's `.gitignore`), or switching the build stage to pnpm so it shares the workspace lock file.

### Issue 2 of 2
examples/nextjs-app/package.json:6-7
**Missing `start` script for local production testing**

The Dockerfile runs `node server.js` directly, but there is no `start` script for users who want to preview the standalone output locally before deploying. Without it, users must know to run `node .next/standalone/server.js` manually. A `start` script keeps parity with the README's `npm install && npm run dev` workflow and matches community expectations for Next.js projects.

```suggestion
    "dev": "next dev",
    "build": "next build",
    "start": "node .next/standalone/server.js"
```

Reviews (1): Last reviewed commit: "feat: add nextjs-app example template" | Re-trigger Greptile

Comment on lines +3 to +4
COPY package.json package-lock.json* ./
RUN npm install

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Non-deterministic dependency installs in Docker build

package-lock.json is listed in the template's .gitignore, so the file is never committed and therefore never present when alien release builds this image. COPY package-lock.json* ./ silently copies nothing, and npm install then resolves semver ranges at build time, meaning successive alien release runs can produce images with different transitive dependency versions. Every other Node.js template in this repo has the same gitignore entry, but here it is the primary production build path. Consider generating and committing a package-lock.json for the example (removing it from the example's .gitignore), or switching the build stage to pnpm so it shares the workspace lock file.

Prompt To Fix With AI
This is a comment left during a code review.
Path: examples/nextjs-app/Dockerfile
Line: 3-4

Comment:
**Non-deterministic dependency installs in Docker build**

`package-lock.json` is listed in the template's `.gitignore`, so the file is never committed and therefore never present when `alien release` builds this image. `COPY package-lock.json* ./` silently copies nothing, and `npm install` then resolves semver ranges at build time, meaning successive `alien release` runs can produce images with different transitive dependency versions. Every other Node.js template in this repo has the same gitignore entry, but here it is the primary production build path. Consider generating and committing a `package-lock.json` for the example (removing it from the example's `.gitignore`), or switching the build stage to pnpm so it shares the workspace lock file.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +6 to +7
"dev": "next dev",
"build": "next build"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing start script for local production testing

The Dockerfile runs node server.js directly, but there is no start script for users who want to preview the standalone output locally before deploying. Without it, users must know to run node .next/standalone/server.js manually. A start script keeps parity with the README's npm install && npm run dev workflow and matches community expectations for Next.js projects.

Suggested change
"dev": "next dev",
"build": "next build"
"dev": "next dev",
"build": "next build",
"start": "node .next/standalone/server.js"
Prompt To Fix With AI
This is a comment left during a code review.
Path: examples/nextjs-app/package.json
Line: 6-7

Comment:
**Missing `start` script for local production testing**

The Dockerfile runs `node server.js` directly, but there is no `start` script for users who want to preview the standalone output locally before deploying. Without it, users must know to run `node .next/standalone/server.js` manually. A `start` script keeps parity with the README's `npm install && npm run dev` workflow and matches community expectations for Next.js projects.

```suggestion
    "dev": "next dev",
    "build": "next build",
    "start": "node .next/standalone/server.js"
```

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant