netstack

edit - ../portals/ - ../../docs/

netbox

version: '3.8'

services:
  netbox:
    image: lscr.io/linuxserver/netbox:latest # Using the LinuxServer.io Netbox image
    container_name: netbox
    environment:
      # These environment variables configure Netbox itself
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      # You can set other Netbox environment variables here, for example:
      # - SUPERUSER_EMAIL=your_email@example.com
      # - SUPERUSER_PASSWORD=your_secure_password
      # - ALLOWED_HOST=your_netbox_domain.com
    volumes:
      - netbox_data:/config # Persistent storage for Netbox configuration and data
      - ./netbox_sqlite_data:/config/sqlite # Mount a directory for the SQLite database
    labels:
      - traefik.enable=true
      - traefik.http.routers.netbox.rule=Host(`your_netbox_domain.com`) # Replace with your domain
      - traefik.http.routers.netbox.entrypoints=websecure # Use HTTPS
      - traefik.http.routers.netbox.tls.certresolver=letsencrypt # If using Let's Encrypt, configure this in Traefik
      - traefik.http.services.netbox.loadbalancer.server.port=8000 # Default Netbox port
    networks:
      - traefik_net

  traefik:
    image: traefik:v3.5 # Or a later version if preferred
    container_name: traefik
    command:
      - "--api.insecure=true" # For development, expose the dashboard insecurely (change for production)
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443" # For HTTPS traffic
      # Optional: Configure Let's Encrypt for automatic TLS certificates
      # - "--certificatesresolvers.letsencrypt.acme.tlschallenge=true"
      # - "--certificatesresolvers.letsencrypt.acme.email=your_email@example.com"
      # - "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080" # Traefik dashboard
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro" # Traefik needs access to Docker socket for container discovery
      # - traefik_letsencrypt:/letsencrypt # Volume for Let's Encrypt certificates (if enabled)
    networks:
      - traefik_net

volumes:
  netbox_data:
  # traefik_letsencrypt: # Declare this volume if using Let's Encrypt with Traefik

networks:
  traefik_net:
    external: false

Netbox Service:

Before you start

To run this stack

Once the containers are running, you should be able to access Netbox through your specified domain (your_netbox_domain.com) via HTTPS. If you’ve exposed the Traefik dashboard, you can access it on port 8080 (e.g., http://your_netbox_domain.com:8080).

This setup provides a robust foundation for your Netbox deployment with persistence, Traefik as a reverse proxy, and a SQLite backend. Remember to adjust the configuration to suit your specific needs and security requirements, especially regarding Traefik’s dashboard access in a production environment.