Skip to content

Commit

Permalink
Merge pull request ionorg#63 from pion/issue-62
Browse files Browse the repository at this point in the history
Fix docker builds for non-local setups
  • Loading branch information
adwpc authored Mar 23, 2020
2 parents 8c60e0e + 6bcbea9 commit cb5e876
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 41 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Welcome contributing to ion!
./scripts/installDeps.sh
#docker
docker-compose build
Building is not required, pre-made images are hosted
```

### 3. run
Expand Down
11 changes: 10 additions & 1 deletion cmd/sfu/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@ import (
)

func init() {
var icePortStart, icePortEnd uint16

if len(conf.WebRTC.ICEPortRange) == 2 {
icePortStart = conf.WebRTC.ICEPortRange[0]
icePortEnd = conf.WebRTC.ICEPortRange[1]
}

log.Init(conf.Log.Level)
rtc.Init(conf.Rtp.Port, conf.WebRTC.ICE, "", "")
if err := rtc.Init(conf.Rtp.Port, conf.WebRTC.ICE, icePortStart, icePortEnd, "", ""); err != nil {
panic(err)
}
}

func main() {
Expand Down
3 changes: 3 additions & 0 deletions configs/sfu.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ addr = "127.0.0.1"
# ice = ["stun:stun.l.google.com:19302"]
# ice = ["stun:stun.stunprotocol.org:3478"]

# Range of ports that ion accepts WebRTC traffic on
ephemeral-udp-port-range = []

[rtp]
# listen port
port = 6666
Expand Down
31 changes: 17 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: '3.7'

services:
# web conference demo
web:
build:
dockerfile: ./docker/web.Dockerfile
context: .
# build:
# dockerfile: ./docker/web.Dockerfile
# context: .
image: pionwebrtc/ion-web
volumes:
- "./configs:/cert"
- "./docker/nginx.conf:/etc/nginx/conf.d/default.conf"
Expand All @@ -15,22 +15,24 @@ services:
- biz

sfu:
build:
dockerfile: ./docker/sfu.Dockerfile
context: .
# build:
# dockerfile: ./docker/sfu.Dockerfile
# context: .
command: "-c /configs/sfu.toml"
image: pionwebrtc/ion-sfu
volumes:
- "./docker/sfu.toml:/configs/sfu.toml"
ports:
- 6666:6666 # rtp
- "5000-5200:5000-5200/udp"
depends_on:
- nats
- etcd

biz:
build:
dockerfile: ./docker/biz.Dockerfile
context: .
# build:
# dockerfile: ./docker/biz.Dockerfile
# context: .
image: pionwebrtc/ion-biz
command: "-c /configs/biz.toml"
volumes:
- "./docker/biz.toml:/configs/biz.toml"
Expand All @@ -43,9 +45,10 @@ services:
- etcd

islb:
build:
dockerfile: ./docker/islb.Dockerfile
context: .
# build:
# dockerfile: ./docker/islb.Dockerfile
# context: .
image: pionwebrtc/ion-islb
command: "-c /configs/islb.toml"
volumes:
- "./docker/islb.toml:/configs/islb.toml"
Expand Down
7 changes: 4 additions & 3 deletions docker/sfu.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ dc = "dc1"
addr = "127.0.0.1"

[webrtc]
# if ion behind nat, uncomment one
# ice = ["stun:stun.l.google.com:19302"]
# ice = ["stun:stun.stunprotocol.org:3478"]
ice = ["stun:stun.l.google.com:19302"]

# Range of ports that ion accepts WebRTC traffic on
ephemeral-udp-port-range = [5000, 5200]

[rtp]
# listen port
Expand Down
3 changes: 2 additions & 1 deletion pkg/conf/sfu/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ type nats struct {
}

type webrtc struct {
ICE []string `mapstructure:"ice"`
ICE []string `mapstructure:"ice"`
ICEPortRange []uint16 `mapstructure:"ephemeral-udp-port-range"`
}

type rtp struct {
Expand Down
8 changes: 5 additions & 3 deletions pkg/rtc/rtc.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ var (
)

// Init port and ice urls
func Init(port int, ices []string, kcpKey, kcpSalt string) error {
func Init(port int, ices []string, icePortStart, icePortEnd uint16, kcpKey, kcpSalt string) error {

//init ice urls and trickle-ICE
transport.InitWebRTC(ices, true, false)
//init ice urls and ICE settings
if err := transport.InitWebRTC(ices, icePortStart, icePortEnd); err != nil {
return err
}

// show stat about all pipelines
go check()
Expand Down
12 changes: 0 additions & 12 deletions pkg/rtc/transport/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,3 @@ func TestKvOK(t *testing.T) {
t.Fatal("flag is not true!")
}
}

func TestValUpper(t *testing.T) {
m := make(map[string]interface{})
m["abc"] = "true"
if ValUpper(m, "abc") != "TRUE" {
t.Fatal("val is not true!")
}
m["abc"] = 1
if ValUpper(m, "abc") != "" {
t.Fatal("ValUpper error!")
}
}
13 changes: 7 additions & 6 deletions pkg/rtc/transport/webrtctransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,18 @@ var (
)

// InitWebRTC init WebRTCTransport setting
func InitWebRTC(ices []string, trickICE bool, liteICE bool) {
func InitWebRTC(ices []string, icePortStart, icePortEnd uint16) error {
var err error
if icePortStart != 0 || icePortEnd != 0 {
err = setting.SetEphemeralUDPPortRange(icePortStart, icePortEnd)
}

cfg.ICEServers = []webrtc.ICEServer{
{
URLs: ices,
},
}
if trickICE {
setting.SetTrickle(trickICE)
} else {
setting.SetLite(liteICE)
}
return err
}

// WebRTCTransport contains pc incoming and outgoing tracks
Expand Down

0 comments on commit cb5e876

Please sign in to comment.