Fixed multi-platform builds (#178)

This commit is contained in:
David Zhao
2021-11-10 15:07:49 -08:00
committed by GitHub
parent 3ff3e91165
commit 0a769662aa
3 changed files with 11 additions and 16 deletions
+5 -1
View File
@@ -1,5 +1,9 @@
FROM golang:1.16-alpine as builder
ARG TARGETPLATFORM
ARG TARGETARCH
RUN echo building for "$TARGETPLATFORM"
WORKDIR /workspace
# Copy the Go Modules manifests
@@ -16,7 +20,7 @@ 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
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH GO111MODULE=on go build -a -o livekit-server ./cmd/server
FROM alpine
+5 -14
View File
@@ -95,27 +95,18 @@ func BuildLinux() error {
return nil
}
// builds docker image for LiveKit server
func Docker() error {
mg.Deps(generateWire)
cmd := exec.Command("docker", "build", ".", "-t", fmt.Sprintf("%s:v%s", imageName, version.Version))
connectStd(cmd)
if err := cmd.Run(); err != nil {
return err
}
return nil
}
// builds and publish snapshot docker image
func PublishDocker() error {
mg.Deps(Docker)
// don't publish snapshot versions as latest or minor version
if !strings.Contains(version.Version, "SNAPSHOT") {
return errors.New("Cannot publish non-snapshot versions")
}
versionImg := fmt.Sprintf("%s:v%s", imageName, version.Version)
cmd := exec.Command("docker", "push", versionImg)
cmd := exec.Command("docker", "buildx", "build",
"--push", "--platform", "linux/amd64,linux/arm64",
"--tag", versionImg,
".")
connectStd(cmd)
if err := cmd.Run(); err != nil {
return err
+1 -1
View File
@@ -1,3 +1,3 @@
package version
const Version = "0.14.0"
const Version = "0.14.1-SNAPSHOT"