mirror of
https://github.com/stefanprodan/podinfo.git
synced 2026-05-05 17:16:57 +00:00
Publish multi-arch image with Docker buildx
This commit is contained in:
20
.github/workflows/build.yml
vendored
Normal file
20
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: '*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: crazy-max/ghaction-docker-buildx@v1
|
||||
- name: build
|
||||
run: |
|
||||
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login --username "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
||||
docker buildx build --platform "linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64" \
|
||||
--output "type=image,push=true" \
|
||||
--build-arg "REVISION=${GITHUB_SHA::8}" \
|
||||
--tag "docker.io/stefanprodan/podinfo:multiarch" \
|
||||
--file Dockerfile .
|
||||
18
Dockerfile
18
Dockerfile
@@ -1,4 +1,6 @@
|
||||
FROM golang:1.14 as builder
|
||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} golang:1.14-alpine as builder
|
||||
|
||||
ARG REVISION
|
||||
|
||||
RUN mkdir -p /podinfo/
|
||||
|
||||
@@ -8,19 +10,15 @@ COPY . .
|
||||
|
||||
RUN go mod download
|
||||
|
||||
RUN go test -v -race ./...
|
||||
|
||||
RUN GIT_COMMIT=$(git rev-list -1 HEAD) && \
|
||||
CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w \
|
||||
-X github.com/stefanprodan/podinfo/pkg/version.REVISION=${GIT_COMMIT}" \
|
||||
RUN CGO_ENABLED=0 go build -ldflags "-s -w \
|
||||
-X github.com/stefanprodan/podinfo/pkg/version.REVISION=${REVISION}" \
|
||||
-a -o bin/podinfo cmd/podinfo/*
|
||||
|
||||
RUN GIT_COMMIT=$(git rev-list -1 HEAD) && \
|
||||
CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w \
|
||||
-X github.com/stefanprodan/podinfo/pkg/version.REVISION=${GIT_COMMIT}" \
|
||||
RUN CGO_ENABLED=0 go build -ldflags "-s -w \
|
||||
-X github.com/stefanprodan/podinfo/pkg/version.REVISION=${REVISION}" \
|
||||
-a -o bin/podcli cmd/podcli/*
|
||||
|
||||
FROM alpine:3.11
|
||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.11
|
||||
|
||||
RUN addgroup -S app \
|
||||
&& adduser -S -g app app \
|
||||
|
||||
Reference in New Issue
Block a user