mirror of
https://github.com/int128/kubelogin.git
synced 2026-02-14 16:39:51 +00:00
Fix multi-platform images (#514)
This commit is contained in:
35
.github/workflows/docker.yaml
vendored
Normal file
35
.github/workflows/docker.yaml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
name: docker
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- .github/workflows/docker.yaml
|
||||
- pkg/**
|
||||
- go.*
|
||||
- Dockerfile
|
||||
tags:
|
||||
- v*
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- .github/workflows/docker.yaml
|
||||
- pkg/**
|
||||
- go.*
|
||||
- Dockerfile
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: docker/setup-qemu-action@v1
|
||||
- uses: docker/setup-buildx-action@v1
|
||||
- uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.CR_PAT }}
|
||||
- run: make docker-build-push
|
||||
14
.github/workflows/go.yaml
vendored
14
.github/workflows/go.yaml
vendored
@@ -84,20 +84,6 @@ jobs:
|
||||
restore-keys: |
|
||||
go-${{ matrix.platform.GOOS }}-${{ matrix.platform.GOARCH }}-
|
||||
- run: make dist
|
||||
|
||||
# Docker image (Linux only)
|
||||
- uses: docker/setup-buildx-action@v1
|
||||
if: runner.os == 'Linux'
|
||||
- uses: docker/login-action@v1
|
||||
if: runner.os == 'Linux'
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.CR_PAT }}
|
||||
- run: make docker-build-push
|
||||
if: runner.os == 'Linux'
|
||||
|
||||
# GitHub Releases
|
||||
- run: make dist-release
|
||||
if: startswith(github.ref, 'refs/tags/')
|
||||
env:
|
||||
|
||||
13
Dockerfile
13
Dockerfile
@@ -1,3 +1,14 @@
|
||||
FROM golang:1.16 as builder
|
||||
|
||||
WORKDIR /builder
|
||||
COPY go.* .
|
||||
RUN go mod download
|
||||
COPY Makefile .
|
||||
COPY main.go .
|
||||
COPY pkg pkg
|
||||
ARG VERSION
|
||||
RUN make VERSION=$VERSION
|
||||
|
||||
FROM gcr.io/distroless/base-debian10
|
||||
COPY kubelogin /
|
||||
COPY --from=builder /builder/kubelogin /
|
||||
ENTRYPOINT ["/kubelogin"]
|
||||
|
||||
15
Makefile
15
Makefile
@@ -2,7 +2,13 @@ TARGET := kubelogin
|
||||
TARGET_ARCHIVE := $(TARGET)_$(GOOS)_$(GOARCH).zip
|
||||
TARGET_DIGEST := $(TARGET)_$(GOOS)_$(GOARCH).zip.sha256
|
||||
|
||||
VERSION := $(notdir $(GITHUB_REF))
|
||||
# determine the version from ref
|
||||
ifeq ($(GITHUB_REF), refs/heads/master)
|
||||
VERSION := latest
|
||||
else
|
||||
VERSION ?= $(notdir $(GITHUB_REF))
|
||||
endif
|
||||
|
||||
LDFLAGS := -X main.version=$(VERSION)
|
||||
|
||||
all: $(TARGET)
|
||||
@@ -33,12 +39,13 @@ dist-release: dist
|
||||
DOCKER_REPOSITORY := ghcr.io/int128/kubelogin
|
||||
|
||||
.PHONY: docker-build-push
|
||||
docker-build-push: Dockerfile $(TARGET)
|
||||
docker-build-push: Dockerfile
|
||||
docker buildx build . \
|
||||
--build-arg=VERSION=$(VERSION) \
|
||||
--tag=$(DOCKER_REPOSITORY):$(VERSION) \
|
||||
--cache-from=type=registry,ref=$(DOCKER_REPOSITORY):master \
|
||||
--cache-from=type=registry,ref=$(DOCKER_REPOSITORY):latest \
|
||||
--cache-to=type=inline \
|
||||
--platform=$(GOOS)/$(GOARCH) \
|
||||
--platform=linux/amd64,linux/arm64 \
|
||||
--push
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
Reference in New Issue
Block a user