127 lines
4.0 KiB
YAML
127 lines
4.0 KiB
YAML
name: Docker Dev
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
CNB_REPOSITORY: "dbxio.com/dbx"
|
|
CNB_REGISTRY: "docker.cnb.cool"
|
|
|
|
jobs:
|
|
docker:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
platform: [linux/amd64, linux/arm64]
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Login to CNB Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.CNB_REGISTRY }}
|
|
username: cnb
|
|
password: ${{ secrets.CNB_TOKEN }}
|
|
|
|
- name: Build and push Docker Hub by digest
|
|
id: build-dockerhub
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: deploy/Dockerfile
|
|
platforms: ${{ matrix.platform }}
|
|
outputs: type=image,name=${{ secrets.DOCKERHUB_USERNAME }}/dbx,push-by-digest=true,name-canonical=true,push=true
|
|
cache-from: type=gha,scope=${{ matrix.platform }}-dev
|
|
cache-to: type=gha,scope=${{ matrix.platform }}-dev,mode=max
|
|
|
|
- name: Build and push CNB by digest
|
|
id: build-cnb
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: deploy/Dockerfile
|
|
platforms: ${{ matrix.platform }}
|
|
outputs: type=image,name=${{ env.CNB_REGISTRY }}/${{ env.CNB_REPOSITORY }},push-by-digest=true,name-canonical=true,push=true
|
|
cache-from: type=gha,scope=${{ matrix.platform }}-dev
|
|
|
|
- name: Export digests
|
|
run: |
|
|
mkdir -p /tmp/digests/dockerhub /tmp/digests/cnb
|
|
dockerhub_digest="${{ steps.build-dockerhub.outputs.digest }}"
|
|
cnb_digest="${{ steps.build-cnb.outputs.digest }}"
|
|
touch "/tmp/digests/dockerhub/${dockerhub_digest#sha256:}"
|
|
touch "/tmp/digests/cnb/${cnb_digest#sha256:}"
|
|
|
|
- name: Upload Docker Hub digest
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: dockerhub-digests-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
|
|
path: /tmp/digests/dockerhub/*
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
- name: Upload CNB digest
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: cnb-digests-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
|
|
path: /tmp/digests/cnb/*
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
docker-manifest:
|
|
needs: docker
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download Docker Hub digests
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
path: /tmp/digests/dockerhub
|
|
pattern: dockerhub-digests-*
|
|
merge-multiple: true
|
|
|
|
- name: Download CNB digests
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
path: /tmp/digests/cnb
|
|
pattern: cnb-digests-*
|
|
merge-multiple: true
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Login to CNB Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.CNB_REGISTRY }}
|
|
username: cnb
|
|
password: ${{ secrets.CNB_TOKEN }}
|
|
|
|
- name: Create manifest list and push
|
|
run: |
|
|
docker buildx imagetools create \
|
|
-t ${{ secrets.DOCKERHUB_USERNAME }}/dbx:dev \
|
|
$(cd /tmp/digests/dockerhub && printf '${{ secrets.DOCKERHUB_USERNAME }}/dbx@sha256:%s ' *)
|
|
|
|
docker buildx imagetools create \
|
|
-t ${{ env.CNB_REGISTRY }}/${{ env.CNB_REPOSITORY }}:dev \
|
|
$(cd /tmp/digests/cnb && printf '${{ env.CNB_REGISTRY }}/${{ env.CNB_REPOSITORY }}@sha256:%s ' *)
|