builds docker image

This commit is contained in:
David Zhao
2021-01-19 22:09:11 -08:00
parent f2e31ebdac
commit 18264e7a8b
4 changed files with 45 additions and 2 deletions
+26
View File
@@ -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"]
+2
View File
@@ -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 {
+14 -2
View File
@@ -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
+3
View File
@@ -0,0 +1,3 @@
package version
const Version = "0.1.1"