summaryrefslogtreecommitdiff
path: root/docker-compose.yml
blob: e92a51ee01adb444a8f9973032d6f2596186e08e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
version: '3.8'

services:
  # Production/Runtime container - lightweight with only runtime dependencies
  torus-app:
    build:
      context: .
      target: runtime
    container_name: go-cuda-torus
    environment:
      - DISPLAY=:0
      - NVIDIA_VISIBLE_DEVICES=all
      - NVIDIA_DRIVER_CAPABILITIES=all
    volumes:
      # X11 socket for display (Linux hosts)
      - /tmp/.X11-unix:/tmp/.X11-unix:rw
    ports:
      - "8080:8080"
    # Enable GPU access
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

  # Development container - includes build tools and source code mounting
  torus-dev:
    build:
      context: .
      target: development
    container_name: go-cuda-torus-dev
    environment:
      - DISPLAY=:0
      - NVIDIA_VISIBLE_DEVICES=all
      - NVIDIA_DRIVER_CAPABILITIES=all
      - CGO_ENABLED=1
    volumes:
      # Mount the source code for live development
      - .:/workspace
      # X11 socket for display (Linux hosts)
      - /tmp/.X11-unix:/tmp/.X11-unix:rw
      # Cache Go modules for faster builds
      - go-mod-cache:/go/pkg/mod
    ports:
      - "8080:8080"
      # - "2345:2345"  # Debug port - do not expose in production
    # Enable GPU access
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
    # For development - override the default command
    command: /bin/bash
    stdin_open: true
    tty: true

  # Build-only container for CI/CD pipelines
  torus-builder:
    build:
      context: .
      target: builder
    container_name: go-cuda-torus-builder
    environment:
      - CGO_ENABLED=1
    volumes:
      - .:/workspace
      - go-mod-cache:/go/pkg/mod
    command: go build -o torus-app .

volumes:
  go-mod-cache: