-
Notifications
You must be signed in to change notification settings - Fork 13
132 lines (124 loc) · 4.49 KB
/
pack.yml
File metadata and controls
132 lines (124 loc) · 4.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# 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) || '' }}