Dockerfile Requirements
What you need in your Dockerfile to deploy on Rock8Cloud
Rock8Cloud deploys any application that has a valid Dockerfile. Here's what you need.
Requirements
Your Dockerfile must:
- Build successfully -
docker build .works without errors - Expose a port - Use
EXPOSE <port>instruction - Start automatically - Use
CMDorENTRYPOINT
Example
Here's a real-world example from astro-rocketship:
# Build stage
FROM oven/bun:1.3.4-alpine AS builder
WORKDIR /app
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile
COPY . .
RUN bun run build
# Production stage
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]This multi-stage build:
- Builds the app with Bun
- Serves static files with nginx
- Results in a small, production-ready image
Port Configuration
The port in your Dockerfile must match what you configure in Rock8Cloud:
Dockerfile:
EXPOSE 3000Rock8Cloud service settings:
- Port:
3000
If they don't match, health checks will fail.
Test Locally First
Before deploying, verify your Dockerfile works:
# Build
docker build -t my-app .
# Run
docker run -p 3000:3000 my-app
# Test
curl http://localhost:3000If it works locally, it'll work on Rock8Cloud.
Monorepo Setup
If your Dockerfile is in a subdirectory, you have two options for build context:
Option 1: Build from repository root (default)
Your Dockerfile references paths from the repo root:
# backend/Dockerfile
FROM node:20-alpine
WORKDIR /app
# Copy from repo root
COPY backend/package.json backend/package-lock.json ./
RUN npm install
COPY backend/ .
RUN npm run build
EXPOSE 3000
CMD ["node", "dist/index.js"]Option 2: Build from Dockerfile directory
Enable "Use Dockerfile directory as build context" in service settings. Your Dockerfile uses relative paths:
# backend/Dockerfile
FROM node:20-alpine
WORKDIR /app
# Copy from backend/ directory
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["node", "dist/index.js"]This option is useful when:
- Each service is self-contained in its folder
- You want faster builds (smaller context)
- Your Dockerfile already uses
COPY . .
Common Issues
| Problem | Solution |
|---|---|
| Build fails | Run docker build . locally to see errors |
| App not accessible | Check your app binds to the correct port |
| Health check fails | Ensure port matches between Dockerfile and settings |
| Missing files | Check all COPY paths exist and aren't in .dockerignore |
| Wrong files copied | Check build context setting matches your Dockerfile's COPY paths |
See FAQ for more help.