Skip to content

Commit

Permalink
Multi-platform docker image build
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldabate authored Feb 21, 2022
1 parent 6d3ab26 commit 7fca7a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/[email protected]

- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Docker Login
uses: docker/[email protected]
with:
Expand All @@ -36,6 +42,7 @@ jobs:
uses: docker/[email protected]
with:
context: .
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# syntax=docker/dockerfile:1

FROM golang:1.18rc1-alpine3.15 AS builder
FROM --platform=${BUILDPLATFORM} golang:1.18rc1-alpine3.15 AS builder

RUN apk add git

WORKDIR /go/src/app
COPY . .

ARG TARGETOS TARGETARCH TARGETVARIANT

ENV CGO_ENABLED=0
RUN go get \
&& go mod download \
&& go build -a -o rtsp-to-web
&& GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${TARGETVARIANT#"v"} go build -a -o rtsp-to-web

FROM alpine:3.15

WORKDIR /app


COPY --from=builder /go/src/app/rtsp-to-web /app/
COPY --from=builder /go/src/app/web /app/web

Expand Down

0 comments on commit 7fca7a1

Please sign in to comment.