Skip to main content

Custom Dockerfile

For full control, add a Dockerfile to your project root. Makofy will use it instead of auto-generating one.

Requirements

Your app must listen on port 8080 (or set via the PORT environment variable).

Example: Node.js

FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --production
COPY . .
EXPOSE 8080
ENV PORT=8080
CMD ["node", "server.js"]

Example: Go

FROM golang:1.23-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o server .

FROM alpine:3.20
RUN apk --no-cache add ca-certificates
COPY --from=builder /app/server /app/server
EXPOSE 8080
CMD ["/app/server"]

Example: Python (FastAPI)

FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8080
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]

Multi-stage builds

Multi-stage builds are fully supported and recommended for production:

FROM node:20-alpine AS builder
WORKDIR /app
COPY . .
RUN npm ci && npm run build

FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]

.dockerignore

Add a .dockerignore to speed up builds by excluding unnecessary files:

node_modules
.git
.env
dist
.next