Skip to content

Commit

Permalink
add github workflow, makefile, dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
chihshenghuang committed Dec 21, 2023
1 parent 993a14b commit 6925678
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/build-publish-mcr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This Github Action will build and publish images to Azure Container Registry(ACR), from where the published images will be
# automatically pushed to the trusted registry, Microsoft Container Registry(MCR).
name: Building and Pushing to MCR
on:
workflow_dispatch:
inputs:
releaseTag:
description: 'Release tag to publish images, defaults to the latest one'
type: string

permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

env:
REGISTRY_REPO: unlisted/aks/eno

jobs:
prepare-variables:
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.vars.outputs.release_tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'Set output variables'
id: vars
run: |
# set the image version
RELEASE_TAG=${{ inputs.releaseTag }}
if [ -z "$RELEASE_TAG" ]; then
RELEASE_TAG=`git describe --tags $(git rev-list --tags --max-count=1)`
echo "The user input release tag is empty, will use the latest tag $RELEASE_TAG."
fi
echo "release_tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
# NOTE: As exporting a variable from a secret is not possible, the shared variable registry obtained
# from AZURE_REGISTRY secret is not exported from here.
publish-images:
runs-on: ubuntu-latest
needs: prepare-variables
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.prepare-variables.outputs.release_tag }}
- name: 'OIDC Login to Azure Public Cloud'
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: 'Login the ACR'
run: az acr login -n ${{ secrets.AZURE_REGISTRY }}
- name: Build and publish eno-manager
run: |
make docker-build-eno-manager
env:
ENO_MANAGER_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.release_tag }}
REGISTRY: ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ifndef TAG
TAG ?= $(shell git rev-parse --short=7 HEAD)
endif
ENO_MANAGER_IMAGE_VERSION ?= $(TAG)
ENO_MANAGER_IMAGE_NAME ?= eno-manager

# Images
OUTPUT_TYPE ?= type=registry

.PHONY: docker-build-eno-manager
docker-build-hub-agent: docker-buildx-builder
docker buildx build \
--file docker/$(ENO_MANAGER_IMAGE_NAME)/Dockerfile \
--output=$(OUTPUT_TYPE) \
--platform="linux/amd64" \
--pull \
--tag $(REGISTRY)/$(ENO_MANAGER_IMAGE_NAME):$(ENO_MANAGER_IMAGE_VERSION) .
8 changes: 8 additions & 0 deletions docker/eno-manager/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM golang:1.21 AS builder
WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 go build -o eno-manager ./internal/manager/manager.go

FROM scratch
COPY --from=builder /app/eno-manager /eno-manager
ENTRYPOINT []

0 comments on commit 6925678

Please sign in to comment.