Use UID 1001 in Dockerfile and set securityContext #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Image | |
on: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- '**.go' | |
- 'go.mod' | |
- 'go.sum' | |
- 'Dockerfile' | |
tags: | |
- 'v**' | |
jobs: | |
buildx: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- 'linux/amd64' | |
- 'linux/arm64' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: true | |
- name: Docker meta | |
id: image-metadata | |
uses: docker/metadata-action@v5 | |
env: | |
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest | |
with: | |
images: | | |
docker.io/superorbital/capargo | |
tags: | | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=sha,enable={{is_default_branch}} | |
type=schedule,pattern={{date 'YYYYMMDD-hhmmss' tz='UTC'}},enable={{is_default_branch}} | |
type=match,pattern=v(\d.\d.\d),group=1,prefix=v,enable=${{ startsWith(github.ref, 'refs/tags/v') }} | |
type=match,pattern=v(\d.\d).\d,group=1,prefix=v,enable=${{ startsWith(github.ref, 'refs/tags/v') }} | |
type=match,pattern=v(\d).\d.\d,group=1,prefix=v,enable=${{ startsWith(github.ref, 'refs/tags/v') }} | |
labels: | | |
org.opencontainers.image.licenses=MIT | |
org.opencontainers.image.authors=SuperOrbital, LLC | |
org.opencontainers.image.description=A controller that automatically registers any Cluster API cluster in your local ArgoCD instance. | |
org.opencontainers.image.documentation=https://github.com/superorbital/${{ github.event.repository.name }}/tree/${{ github.sha }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.opencontainers.image.source=https://github.com/superorbital/${{ github.event.repository.name }}/tree/${{ github.sha }} | |
org.opencontainers.image.title=${{ matrix.directory }} | |
org.opencontainers.image.url=https://github.com/superorbital/${{ github.event.repository.name }}/tree/${{ github.sha }} | |
org.opencontainers.image.vendor=SuperOrbital, LLC | |
annotations: | | |
org.opencontainers.image.licenses=MIT | |
org.opencontainers.image.authors=SuperOrbital, LLC | |
org.opencontainers.image.description=A controller that automatically registers any Cluster API cluster in your local ArgoCD instance. | |
org.opencontainers.image.documentation=https://github.com/superorbital/${{ github.event.repository.name }}/tree/${{ github.sha }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.opencontainers.image.source=https://github.com/superorbital/${{ github.event.repository.name }}/tree/${{ github.sha }} | |
org.opencontainers.image.title=${{ matrix.directory }} | |
org.opencontainers.image.url=https://github.com/superorbital/${{ github.event.repository.name }}/tree/${{ github.sha }} | |
org.opencontainers.image.vendor=SuperOrbital, LLC | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Available platforms | |
run: echo ${{ steps.buildx.outputs.platforms }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v5 | |
with: | |
provenance: false | |
sbom: false | |
build-args: | | |
BUILDTIME=${{ fromJSON(steps.image-metadata.outputs.json).labels['org.opencontainers.image.created'] }} | |
VERSION=${{ fromJSON(steps.image-metadata.outputs.json).labels['org.opencontainers.image.version'] }} | |
REVISION=${{ fromJSON(steps.image-metadata.outputs.json).labels['org.opencontainers.image.revision'] }} | |
context: '.' | |
file: Dockerfile | |
platforms: ${{ matrix.platform }} | |
push: true | |
tags: ${{ steps.image-metadata.outputs.tags }} | |
labels: ${{ steps.image-metadata.outputs.labels }} | |
annotations: ${{ steps.image-metadata.outputs.annotations }} |