Skip to content

Commit

Permalink
add docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinForReal committed Jan 15, 2024
1 parent 3d92a2c commit 16b5bb4
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ permissions:
jobs:
build-azure-ipoib-ipam-cni:
runs-on: ubuntu-latest
permissions:
packages: write
actions: read
contents: read
strategy:
matrix:
include:
Expand All @@ -38,6 +42,20 @@ jobs:
name: azure-ipoib-ipam-cni-${{ matrix.os }}-${{ matrix.arch }}
path: bin/azure-ipoib-ipam-cni-${{ matrix.os }}-${{ matrix.arch }}
if-no-files-found: error
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: ${{ matrix.platforms }}
push: true
tags: ghcr.io/azure/azure-ipoib-ipam-cni:${{ matrix.os }}-${{ matrix.arch }}
publish:
runs-on: ubuntu-latest
needs:
Expand All @@ -54,4 +72,4 @@ jobs:
uses: softprops/action-gh-release@v1 # v1
with:
files: |
./artifacts/azure-ipoib-ipam-cni-*-*/*
./artifacts/azure-ipoib-ipam-cni-*-*/*
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang as builder

COPY . /workspace/
WORKDIR /workspace/
RUN make build

FROM gcr.io/distroless/static-debian12
COPY --from=builder /workspace/bin/* /
ENTRYPOINT ["/install"]
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ vet: golangci-lint ## Run go vet against code.
##@ Build

.PHONY: build
build: $(LOCALBIN) fmt vet ## Build manager binary.
build: clean $(LOCALBIN) fmt vet ## Build manager binary.
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -o bin/azure-ipoib-ipam-cni ./cmd/
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -o bin/install ./cmd/install
##@ Build Dependencies

.PHONY: install-dependencies
Expand Down Expand Up @@ -75,4 +76,8 @@ GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
test -s $(LOCALBIN)/golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(LOCALBIN) latest
test -s $(LOCALBIN)/golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(LOCALBIN) latest

.PHONY: clean
clean:
rm -rf $(LOCALBIN)
20 changes: 20 additions & 0 deletions cmd/install/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package main

import (
"fmt"
"os"
)

func main() {
content, err := os.ReadFile("azure-ipoib-ipam-cni")
if err != nil {
fmt.Printf("failed to find file: %s", err.Error())
os.Exit(1)
}
if err := os.WriteFile("/opt/cni/bin/azure-ipoib-ipam-cni", content, 0755); err != nil {
fmt.Printf("failed to write file: %s", err.Error())
os.Exit(1)
}
}

0 comments on commit 16b5bb4

Please sign in to comment.