Skip to content

Commit

Permalink
Migrate from docker hub to ghcr.io (#57)
Browse files Browse the repository at this point in the history
* Migrate to github registry
  • Loading branch information
digiserg authored Mar 15, 2023
1 parent 655443e commit c7bc6fb
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 19 deletions.
52 changes: 38 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,53 @@ jobs:
release:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Build the Docker image
run: docker build . --file Dockerfile --tag digitalisdocker/vals-operator
- name: Setup mirror
uses: self-actuated/hub-mirror@master

- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get TAG
id: get_tag
run: echo TAG=${GITHUB_REF##*/} >> $GITHUB_ENV

- name: Get Repo Owner
id: get_repo_owner
run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" > $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: "Get docker info"
run: |
echo "Actor: ${{ github.actor }}"
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
- name: "Log into GitHub Container Registry"
if: "github.event_name != 'pull_request'"
uses: "docker/login-action@v1"
with:
images: digitalisdocker/vals-operator
registry: "ghcr.io"
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
uses: docker/build-push-action@v4
with:
platforms: linux/amd64,linux/arm/v6,linux/arm64
build-args: |
VERSION=${{ env.TAG }}
GitCommit=${{ github.sha }}
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tags: |
ghcr.io/${{ env.REPO_OWNER }}/vals-operator:${{ github.sha }}
ghcr.io/${{ env.REPO_OWNER }}/vals-operator:${{ env.TAG }}
ghcr.io/${{ env.REPO_OWNER }}/vals-operator:latest
labels: |
LABEL org.opencontainers.image.source="https://github.com/${{ env.REPO_OWNER }}/vals-operator"
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Build the vals-operator binary
FROM golang:1.19 as builder
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.19 as builder

ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH

ARG TARGETOS
ARG TARGETARCH
Expand All @@ -26,7 +30,7 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} go build -

# Use distroless as minimal base image to package the vals-operator binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
FROM --platform=${BUILDPLATFORM:-linux/amd64} gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/vals-operator /vals-operator
USER 65532:65532
Expand Down
3 changes: 2 additions & 1 deletion charts/vals-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ kubeVersion: ">= 1.19.0-0"
type: application

# Chart version
version: 0.7.0
version: 0.7.1

# Latest container tag
appVersion: "0.7.0"

Expand Down
2 changes: 1 addition & 1 deletion charts/vals-operator/values.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
replicaCount: 1

image:
repository: digitalisdocker/vals-operator
repository: ghcr.io/digitalis-io/vals-operator
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
Expand Down

0 comments on commit c7bc6fb

Please sign in to comment.