Skip to content

Docker Build and Publish Allinone #57

Docker Build and Publish Allinone

Docker Build and Publish Allinone #57

name: Docker Build and Publish Allinone
on:
push:
tags:
- 'v*'
paths:
- 'cmd/**'
- 'internal/**'
- 'pkg/**'
- 'deploy/docker/**'
- 'go.mod'
- 'go.sum'
workflow_dispatch:
env:
DOCKER_HUB_USERNAME: ifuryst
ALIYUN_REGISTRY: registry.ap-southeast-1.aliyuncs.com/amoylab
BUILDX_NO_DEFAULT_ATTESTATIONS: 1
PUSH_LATEST: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
SHOULD_LOGIN: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Set lowercase repository
run: echo "LOWERCASE_REPO=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Login to Docker Hub
if: env.SHOULD_LOGIN == 'true'
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Login to GitHub Container Registry
if: env.SHOULD_LOGIN == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Aliyun Container Registry
if: env.SHOULD_LOGIN == 'true'
uses: docker/login-action@v3
with:
registry: ${{ env.ALIYUN_REGISTRY }}
username: ${{ secrets.ALIYUN_USERNAME }}
password: ${{ secrets.ALIYUN_PASSWORD }}
- name: Build and push allinone image
uses: docker/build-push-action@v5
with:
context: .
file: deploy/docker/allinone/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
UV_DEFAULT_INDEX=https://mirrors.aliyun.com/pypi/simple/
pnpm_config_registry=https://registry.npmmirror.com
tags: |
${{ env.PUSH_LATEST == 'true' && format('{0}/unla-allinone:latest', env.DOCKER_HUB_USERNAME) || '' }}
${{ format('{0}/unla-allinone:{1}', env.DOCKER_HUB_USERNAME, github.ref_name) }}
${{ env.PUSH_LATEST == 'true' && format('ghcr.io/{0}/allinone:latest', env.LOWERCASE_REPO) || '' }}
${{ format('ghcr.io/{0}/allinone:{1}', env.LOWERCASE_REPO, github.ref_name) }}
${{ env.PUSH_LATEST == 'true' && format('{0}/unla-allinone:latest', env.ALIYUN_REGISTRY) || '' }}
${{ format('{0}/unla-allinone:{1}', env.ALIYUN_REGISTRY, github.ref_name) }}