feat: support docker container mem_limit/cpu_shares configable #230
Workflow file for this run
This file contains hidden or 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
| # This workflow packs the Docker images for the GPUStack runtime. | |
| name: pack | |
| permissions: | |
| actions: read | |
| contents: write | |
| pull-requests: write | |
| defaults: | |
| run: | |
| shell: bash | |
| on: | |
| workflow_dispatch: {} | |
| push: | |
| branches: | |
| - "main" | |
| - "v*-dev" | |
| tags: | |
| - "v*.*.*" | |
| pull_request: | |
| branches: | |
| - "main" | |
| - "v*-dev" | |
| env: | |
| INPUT_PYTHON_VERSION: 3.11 | |
| INPUT_USERNAME: gpustack | |
| INPUT_PASSWORD: ${{ secrets.CI_DOCKERHUB_PASSWORD }} | |
| INPUT_NAMESPACE: gpustack | |
| INPUT_REPOSITORY: runtime | |
| jobs: | |
| pack: | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 360 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| persist-credentials: false | |
| - name: Setup UV | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: "0.8.24" | |
| enable-cache: true | |
| python-version: ${{ env.INPUT_PYTHON_VERSION }} | |
| - name: Setup QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| image: tonistiigi/binfmt:qemu-v9.2.2 | |
| platforms: "arm64" | |
| - name: Setup BuildX | |
| id: setup-buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver-opts: | | |
| network=host | |
| env.BUILDKIT_STEP_LOG_MAX_SIZE=-1 | |
| env.BUILDKIT_STEP_LOG_MAX_SPEED=-1 | |
| buildkitd-flags: | | |
| --allow-insecure-entitlement=network.host | |
| --allow-insecure-entitlement=security.insecure | |
| --oci-worker-net=host | |
| --oci-worker-gc-keepstorage=204800 | |
| - name: Setup BuildX Cache | |
| id: setup-buildx-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ github.workspace }}/.cache | |
| key: cache-mount-${{ hashFiles('uv.lock') }} | |
| - name: Restore BuildX Cache | |
| uses: reproducible-containers/buildkit-cache-dance@v3 | |
| with: | |
| builder: ${{ steps.setup-buildx.outputs.name }} | |
| cache-dir: ${{ github.workspace }}/.cache | |
| dockerfile: ${{ github.workspace }}/pack/Dockerfile | |
| skip-extraction: ${{ steps.setup-buildx-cache.outputs.cache-hit }} | |
| - name: Login DockerHub | |
| if: ${{ github.event_name != 'pull_request' }} | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ env.INPUT_USERNAME }} | |
| password: ${{ env.INPUT_PASSWORD }} | |
| - name: Get Metadata | |
| id: metadata | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: "${{ env.INPUT_NAMESPACE }}/${{ env.INPUT_REPOSITORY }}" | |
| - name: Get Image Labels | |
| run: | | |
| #!/usr/bin/env bash | |
| set -eo pipefail | |
| LABELS=( | |
| "org.opencontainers.image.source=${{ fromJSON(steps.metadata.outputs.json).labels['org.opencontainers.image.source'] }}" | |
| "org.opencontainers.image.version=${{ fromJSON(steps.metadata.outputs.json).labels['org.opencontainers.image.version'] }}" | |
| "org.opencontainers.image.revision=${{ fromJSON(steps.metadata.outputs.json).labels['org.opencontainers.image.revision'] }}" | |
| "org.opencontainers.image.created=${{ fromJSON(steps.metadata.outputs.json).labels['org.opencontainers.image.created'] }}" | |
| ) | |
| INPUT_DOCKER_MIRRORED_NAME_FILTER_LABELS=$(printf "%s;" "${LABELS[@]}") | |
| echo "INPUT_DOCKER_MIRRORED_NAME_FILTER_LABELS=${INPUT_DOCKER_MIRRORED_NAME_FILTER_LABELS}" >> $GITHUB_ENV | |
| - name: Package | |
| uses: docker/build-push-action@v6 | |
| with: | |
| allow: | | |
| network.host | |
| security.insecure | |
| ulimit: | | |
| nofile=65536:65536 | |
| shm-size: "16G" | |
| provenance: true | |
| sbom: true | |
| push: ${{ github.event_name != 'pull_request' }} | |
| file: ${{ github.workspace }}/pack/Dockerfile | |
| context: ${{ github.workspace }} | |
| platforms: "linux/amd64,linux/arm64" | |
| build-args: | | |
| PYTHON_VERSION=${{ env.INPUT_PYTHON_VERSION }} | |
| GPUSTACK_RUNTIME_DOCKER_MIRRORED_NAME_FILTER_LABELS=${{ env.INPUT_DOCKER_MIRRORED_NAME_FILTER_LABELS }} | |
| tags: | | |
| ${{ steps.metadata.outputs.tags }} | |
| labels: | | |
| ${{ steps.metadata.outputs.labels }} | |
| cache-from: | | |
| type=registry,ref=${{ env.INPUT_NAMESPACE }}/${{ env.INPUT_REPOSITORY }}:build-cache | |
| cache-to: | | |
| ${{ github.event_name != 'pull_request' && format('type=registry,mode=max,compression=gzip,ref={0}/{1}:build-cache,ignore-error=true', env.INPUT_NAMESPACE, env.INPUT_REPOSITORY) || '' }} |