Deploying a server app with a Dockerfile
A static site is built and uploaded; a server app runs a container. LeafCloud never writes a Dockerfile for you. If a repository needs a server and has no Dockerfile at its root, planning it from GitHub is refused with a fix pointing to this page.
When you need one
Section titled “When you need one”- The framework produces server output: Next.js without
output: 'export', Nuxt SSR, SvelteKit withadapter-node, Remix, Astro withoutput: "server"or"hybrid". - Plain Node servers such as Express or Fastify, and servers written in Python, Go or another language.
- Any other project that must run a process rather than upload a built folder.
If your framework can export a static site, use the static route instead — it needs no Dockerfile.
What LeafCloud expects
Section titled “What LeafCloud expects”- A
Dockerfileat the repository root.Containerfilealso works. - The process listens on all interfaces,
0.0.0.0, not onlylocalhost. - It listens on the port you plan with: read
$PORTwhen the app is configured to use the platform port, or state a fixed port in the Dockerfile and use that same port in the plan.EXPOSEis documentation; the plan’s port is what is routed. - A health path that returns a successful response, such as
/healthz. The plan proposes/healthz; a simpleHEALTHCHECKin the Dockerfile makes the expectation explicit. Keep that endpoint shallow: it should not call a database or any other service. A plain TCP check, which only needs the port to accept a connection, is the default when an app has no health path; see Health check.
Node / Express
Section titled “Node / Express”const express = require('express');const app = express();app.get('/healthz', (_req, res) => res.send('ok'));app.listen(Number(process.env.PORT || 8080), '0.0.0.0');FROM node:20-alpineWORKDIR /appCOPY package*.json ./RUN npm ci --omit=devCOPY . .ENV PORT=8080EXPOSE 8080HEALTHCHECK CMD wget -q -O - http://localhost:8080/healthz || exit 1CMD ["node", "server.js"]Next.js (standalone output)
Section titled “Next.js (standalone output)”export default { output: 'standalone' };FROM node:20-alpine AS buildWORKDIR /appCOPY package*.json ./RUN npm ciCOPY . .RUN npm run build
FROM node:20-alpineWORKDIR /appENV NODE_ENV=production PORT=3000 HOSTNAME=0.0.0.0COPY --from=build /app/.next/standalone ./COPY --from=build /app/.next/static ./.next/staticCOPY --from=build /app/public ./publicEXPOSE 3000HEALTHCHECK CMD wget -q -O - http://localhost:3000/healthz || exit 1CMD ["node", "server.js"]Add a app/api/healthz/route.ts (or your framework’s health route) that returns 200.
Astro SSR with @astrojs/node
Section titled “Astro SSR with @astrojs/node”import { defineConfig } from 'astro/config';import node from '@astrojs/node';
export default defineConfig({ output: 'server', adapter: node({ mode: 'standalone' }),});FROM node:20-alpine AS buildWORKDIR /appCOPY package*.json ./RUN npm ciCOPY . .RUN npm run build
FROM node:20-alpineWORKDIR /appENV NODE_ENV=production PORT=4321 HOST=0.0.0.0COPY --from=build /app/node_modules ./node_modulesCOPY --from=build /app/dist ./distCOPY --from=build /app/package.json ./package.jsonEXPOSE 4321HEALTHCHECK CMD wget -q -O - http://localhost:4321/healthz || exit 1CMD ["node", "./dist/server/entry.mjs"]Commit the Dockerfile, then plan the repository again from the dashboard. The setup pull request adds only the deploy workflow; your Dockerfile stays in your repository.