name: Docker on: push: branches: [main] tags: ["v*"] paths-ignore: - "docs/**" - "**.md" - "devenv/**" release: types: [published] pull_request: branches: [main] paths-ignore: - "docs/**" - "**.md" - "devenv/**" workflow_dispatch: concurrency: group: docker-${{ github.ref }} cancel-in-progress: true permissions: contents: read packages: write id-token: write jobs: docker: runs-on: ubuntu-latest strategy: matrix: include: - image: server dockerfile: docker/Dockerfile.server - image: agent dockerfile: docker/Dockerfile.agent - image: web dockerfile: docker/Dockerfile.web - image: mcp dockerfile: docker/Dockerfile.mcp steps: - name: Checkout uses: actions/checkout@v4 - name: Docker meta id: meta uses: docker/metadata-action@v5 with: images: | memohai/${{ matrix.image }} ghcr.io/${{ github.repository_owner }}/${{ matrix.image }} tags: | type=raw,value=dev,enable=${{ github.ref == 'refs/heads/main' }} type=raw,value=latest,enable=${{ github.event_name == 'release' || (startsWith(github.ref, 'refs/tags/') && !contains(github.ref_name, '-')) }} type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} type=sha labels: | org.opencontainers.image.title=memoh-${{ matrix.image }} org.opencontainers.image.description=Memoh ${{ matrix.image }} - Multi-member AI agent platform org.opencontainers.image.vendor=memohai - name: Set up QEMU if: startsWith(github.ref, 'refs/tags/') uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push uses: docker/build-push-action@v6 with: context: . file: ${{ matrix.dockerfile }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64' || 'linux/amd64' }} build-args: | VERSION=${{ steps.meta.outputs.version }} COMMIT_HASH=${{ github.sha }} BUILD_TIME=${{ fromJson(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} VITE_API_URL=/api VITE_AGENT_URL=/agent provenance: ${{ startsWith(github.ref, 'refs/tags/') }} sbom: ${{ startsWith(github.ref, 'refs/tags/') }} cache-from: type=gha,scope=${{ matrix.image }} cache-to: type=gha,scope=${{ matrix.image }},mode=max