Deploy Docker
If a Dockerfile exists in your project root, Leash uses it directly instead of auto-detecting a framework. This gives you full control over the build process.
Detection
A Dockerfile in the project root takes priority over all other detection. Leash builds the image from your Dockerfile and deploys it.
Terminal
$ leash deploy
✓ Detected Dockerfile
✓ Building from Dockerfile...
✓ Image built and pushed
✓ Deployed successfully!
→ https://my-app-arvin.un.leash.build
When to Use a Dockerfile
- You need system-level dependencies not covered by Nixpacks
- You want multi-stage builds for smaller images
- Your app uses a language or framework Leash doesn't auto-detect
- You need precise control over the runtime environment
PORT Environment Variable
Important: expose the right port
Your container must listen on the port specified by the PORT environment variable (defaults to 8080). Use EXPOSE 8080 in your Dockerfile and read $PORT at runtime.
Example Dockerfile
A multi-stage Node.js Dockerfile that produces a small production image:
Dockerfile
FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm install COPY . . RUN npm run build FROM node:20-alpine WORKDIR /app COPY --from=builder /app/dist ./dist COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/package.json ./ EXPOSE 8080 CMD ["node", "dist/index.js"]