(subdomain, projectName string, port uint, dotnhostfolder string)
| 247 | } |
| 248 | |
| 249 | func traefik(subdomain, projectName string, port uint, dotnhostfolder string) (*Service, error) { |
| 250 | if err := trafikFiles(dotnhostfolder); err != nil { |
| 251 | return nil, fmt.Errorf("failed to create traefik files: %w", err) |
| 252 | } |
| 253 | |
| 254 | dockerURL, err := getDockerHost() |
| 255 | if err != nil { |
| 256 | return nil, fmt.Errorf("failed to get docker host: %w", err) |
| 257 | } |
| 258 | |
| 259 | volumes := []Volume{{ |
| 260 | Type: "bind", |
| 261 | Source: filepath.Join(dotnhostfolder, "traefik"), |
| 262 | Target: "/opt/traefik", |
| 263 | ReadOnly: new(true), |
| 264 | }} |
| 265 | |
| 266 | dockerEndpoint := dockerURL.String() |
| 267 | if dockerURL.Scheme == "unix" { |
| 268 | volumes = append(volumes, Volume{ |
| 269 | Type: "bind", |
| 270 | Source: dockerURL.Path, |
| 271 | Target: "/var/run/docker.sock", |
| 272 | ReadOnly: new(true), |
| 273 | }) |
| 274 | dockerEndpoint = "unix:///var/run/docker.sock" |
| 275 | } |
| 276 | |
| 277 | return &Service{ |
| 278 | Image: "traefik:v3.6", |
| 279 | DependsOn: nil, |
| 280 | EntryPoint: nil, |
| 281 | Command: []string{ |
| 282 | "--api.insecure=true", |
| 283 | "--providers.docker=true", |
| 284 | "--providers.docker.endpoint=" + dockerEndpoint, |
| 285 | "--providers.file.directory=/opt/traefik", |
| 286 | "--providers.file.watch=true", |
| 287 | "--providers.docker.exposedbydefault=false", |
| 288 | fmt.Sprintf( |
| 289 | "--providers.docker.constraints=Label(`com.docker.compose.project`,`%s`)", |
| 290 | projectName, |
| 291 | ), |
| 292 | fmt.Sprintf("--entrypoints.web.address=:%d", port), |
| 293 | }, |
| 294 | Environment: nil, |
| 295 | ExtraHosts: extraHosts(subdomain), |
| 296 | HealthCheck: nil, |
| 297 | Labels: nil, |
| 298 | Networks: nil, |
| 299 | Ports: []Port{ |
| 300 | { |
| 301 | Mode: "ingress", |
| 302 | Target: port, |
| 303 | Published: strconv.FormatUint(uint64(port), 10), |
| 304 | Protocol: "tcp", |
| 305 | }, |
| 306 | }, |
no test coverage detected