diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..e80a050bc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM golang:alpine as builder + +WORKDIR /workspace +# Copy the Go Modules manifests +COPY go.mod go.mod +COPY go.sum go.sum +# cache deps before building and copying source so that we don't need to re-download as much +# and so that source changes don't invalidate our downloaded layer +RUN go mod download + +# Copy the go source +COPY cmd/ cmd/ +COPY pkg/ pkg/ +COPY proto/ proto/ +COPY test/ test/ +COPY tools/ tools/ +COPY version/ version/ + +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o livekit-server ./cmd/server + +FROM scratch + +COPY --from=builder /workspace/livekit-server /livekit-server + +# Run the binary. +ENTRYPOINT ["/livekit-server"] diff --git a/cmd/server/main.go b/cmd/server/main.go index 97ba3697b..14bea2d07 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -22,6 +22,7 @@ import ( "github.com/livekit/livekit-server/pkg/routing" "github.com/livekit/livekit-server/pkg/service" "github.com/livekit/livekit-server/pkg/utils" + "github.com/livekit/livekit-server/version" ) func main() { @@ -67,6 +68,7 @@ func main() { Action: generateKeys, }, }, + Version: version.Version, } if err := app.Run(os.Args); err != nil { diff --git a/magefile.go b/magefile.go index b8f54d190..70a481b77 100644 --- a/magefile.go +++ b/magefile.go @@ -7,15 +7,16 @@ import ( "fmt" "go/build" "io/ioutil" + "log" "os" "os/exec" "path/filepath" "sort" "strings" + "github.com/livekit/livekit-server/version" "github.com/magefile/mage/mg" "github.com/magefile/mage/target" - log "github.com/pion/ion-log" ) const ( @@ -134,6 +135,17 @@ func Build() error { return nil } +// builds docker image for LiveKit server +func BuildDocker() error { + mg.Deps(Proto, generateWire) + cmd := exec.Command("docker", "build", ".", "-t", "livekit/livekit:v"+version.Version) + connectStd(cmd) + if err := cmd.Run(); err != nil { + return err + } + return nil +} + // run unit tests, skipping integration func Test() error { mg.Deps(Proto) @@ -296,7 +308,7 @@ func NewChecksummer(dir string, checksumfile string, exts ...string) *Checksumme func (c *Checksummer) IsChanged() bool { // default changed if err := c.computeChecksum(); err != nil { - log.Errorf("could not compute checksum: %v", err) + log.Println("could not compute checksum", err) return true } // read diff --git a/version/version.go b/version/version.go new file mode 100644 index 000000000..ec1cdb3b2 --- /dev/null +++ b/version/version.go @@ -0,0 +1,3 @@ +package version + +const Version = "0.1.1"