AbsoluteJS

Docker

Containerize your AbsoluteJS application for consistent deployments across any environment.

#Dockerfile

A production-ready Dockerfile using the official Bun image. The --host flag ensures the server binds to all interfaces for Docker networking:

DOCKER
FROM oven/bun:1.2

WORKDIR /app

# Copy package files
COPY package.json bun.lockb ./

# Install dependencies
RUN bun install --frozen-lockfile

# Copy source code
COPY . .

# Build the application
RUN bun run build

# Expose port
EXPOSE 3000

# Start the server with --host for Docker networking
CMD ["bun", "run", "src/backend/server.ts", "--host"]

#Docker Compose

For local development or simple deployments, use Docker Compose to run your app with a database:

YAML
version: '3.8'

services:
  app:
    build: .
    ports:
      - "3000:3000"
    environment:
      - DATABASE_URL=${DATABASE_URL}
      - NODE_ENV=production
    depends_on:
      - db

  db:
    image: postgres:16
    environment:
      - POSTGRES_USER=app
      - POSTGRES_PASSWORD=secret
      - POSTGRES_DB=myapp
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

#Best Practices

Use --frozen-lockfileEnsures reproducible builds by using exact versions from bun.lockb
Multi-stage buildsSeparate build and runtime stages to reduce final image size
Don't run as rootAdd a non-root user for better security
Use .dockerignoreExclude node_modules, .git, and other unnecessary files
Health checksAdd HEALTHCHECK instruction for container orchestration