Skip to main content

Overview

The Docker deployment uses a multi-stage build process to create a lightweight production image with nginx serving the Sable application.

Dockerfile Breakdown

The Dockerfile consists of two stages:

Builder Stage

The first stage builds the application:
FROM node:24.13.1-alpine AS builder

WORKDIR /src

COPY .npmrc package.json package-lock.json /src/
RUN npm ci
COPY . /src/
ENV NODE_OPTIONS=--max_old_space_size=4096
RUN npm run build
  • Uses Node.js 24.13.1 Alpine image for smaller size
  • Installs dependencies with npm ci for reproducible builds
  • Sets heap size to 4GB to handle large builds
  • Compiles the application to the dist/ directory

App Stage

The second stage creates the production image:
FROM nginx:1.29.5-alpine

COPY --from=builder /src/dist /app
COPY --from=builder /src/docker-nginx.conf /etc/nginx/conf.d/default.conf

RUN rm -rf /usr/share/nginx/html \
  && ln -s /app /usr/share/nginx/html
  • Uses nginx 1.29.5 Alpine image
  • Copies built application from builder stage
  • Includes custom nginx configuration
  • Creates symbolic link for nginx to serve the app

Building the Docker Image

1

Clone the repository

git clone https://github.com/7w1/sable.git
cd sable
2

Build the Docker image

docker build -t sable:latest .
This creates a Docker image tagged as sable:latest.
3

Run the container

docker run -d -p 80:80 --name sable sable:latest
This starts the container and maps port 80 to your host.

Docker Run Options

docker run -d -p 80:80 --name sable sable:latest

Docker Compose

For easier management, use Docker Compose:
docker-compose.yml
version: '3.8'

services:
  sable:
    build: .
    ports:
      - "80:80"
    volumes:
      - ./config.json:/app/config.json:ro
    restart: unless-stopped
Run with:
docker compose up -d

Configuration

Custom config.json

To use a custom configuration file, mount it as a volume:
docker run -d -p 80:80 \
  -v /path/to/your/config.json:/app/config.json:ro \
  --name sable sable:latest

Environment Variables

The build process uses the following environment variable:
  • NODE_OPTIONS=--max_old_space_size=4096: Increases Node.js heap size to 4GB for the build process
The NODE_OPTIONS environment variable is only used during the build stage and does not affect the running application.

Nginx Configuration

The Docker image includes a pre-configured nginx setup from docker-nginx.conf. The configuration:
  • Listens on port 80 (IPv4 and IPv6)
  • Serves the application from /usr/share/nginx/html
  • Handles routing for single-page application
  • Properly serves static assets and service workers
For details on the nginx configuration, see the Nginx Configuration guide.

Updating

To update your Sable deployment:
1

Pull latest changes

git pull origin main
2

Rebuild the image

docker build -t sable:latest .
3

Stop and remove old container

docker stop sable
docker rm sable
4

Start new container

docker run -d -p 80:80 --name sable sable:latest
Or with Docker Compose:
docker compose down
docker compose build
docker compose up -d

Build docs developers (and LLMs) love