-
Notifications
You must be signed in to change notification settings - Fork 29
add model package #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
add model package #230
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: build-model | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - 'main' | ||
| - 'model/[0-9]+.[0-9]+' | ||
| paths: | ||
| - '.github/workflows/.build.yml' | ||
| - '.github/workflows/build-model.yml' | ||
| - 'hack/scripts/**' | ||
| - 'pkg/model/**' | ||
| - 'docker-bake.hcl' | ||
| pull_request: | ||
| branches: | ||
| - 'main' | ||
| - 'model/[0-9]+.[0-9]+' | ||
| paths: | ||
| - '.github/workflows/.build.yml' | ||
| - '.github/workflows/build-model.yml' | ||
| - 'hack/scripts/**' | ||
| - 'pkg/model/**' | ||
| - 'docker-bake.hcl' | ||
|
|
||
| jobs: | ||
| run: | ||
| uses: ./.github/workflows/.build.yml | ||
| with: | ||
| name: model | ||
| secrets: inherit |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: release-model | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| ref: | ||
| description: 'Ref (e.g. v0.1.30)' | ||
| required: true | ||
| type: string | ||
| repo: | ||
| description: 'Override default repo' | ||
| required: false | ||
| type: string | ||
| release: | ||
| description: 'Push image and create release' | ||
| required: false | ||
| type: boolean | ||
|
|
||
| jobs: | ||
| release: | ||
| uses: ./.github/workflows/.build.yml | ||
| with: | ||
| name: model | ||
| release: ${{ inputs.release }} | ||
| push: ${{ inputs.release }} | ||
| envs: | | ||
| PKG_REPO=${{ inputs.repo }} | ||
| PKG_REF=${{ inputs.ref }} | ||
| secrets: inherit |
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 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 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 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| # syntax=docker/dockerfile:1 | ||
|
|
||
| # Copyright 2025 Docker Packaging authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| ARG XX_VERSION="1.6.1" | ||
| ARG DEBIAN_FRONTEND="noninteractive" | ||
|
|
||
| ARG DISTRO_NAME="debian12" | ||
| ARG DISTRO_TYPE="deb" | ||
| ARG DISTRO_RELEASE="debian" | ||
| ARG DISTRO_SUITE="bookworm" | ||
| ARG DISTRO_ID="12" | ||
| ARG DISTRO_IMAGE="debian:bookworm" | ||
|
|
||
| ARG PKG_NAME="docker-model-plugin" | ||
| ARG PKG_REPO="https://github.com/docker/model-cli.git" | ||
| ARG PKG_REF="main" | ||
|
|
||
| ARG GO_IMAGE="golang" | ||
| ARG GO_VERSION="1.24.4" | ||
| ARG GO_IMAGE_VARIANT="bookworm" | ||
|
|
||
| # stage used as named context that mounts hack/scripts | ||
| # see pkg target in docker-bake.hcl | ||
| FROM scratch AS scripts | ||
|
|
||
| # cross compilation helper | ||
| FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx | ||
|
|
||
| # go base image to retrieve /usr/local/go | ||
| FROM ${GO_IMAGE}:${GO_VERSION}-${GO_IMAGE_VARIANT} AS go | ||
| FROM --platform=$BUILDPLATFORM ${GO_IMAGE}:${GO_VERSION}-${GO_IMAGE_VARIANT} AS gocross | ||
|
|
||
| # src | ||
| FROM --platform=$BUILDPLATFORM alpine AS src-base | ||
| RUN apk add --no-cache bash curl file git zip tar | ||
|
|
||
| FROM src-base AS src | ||
| WORKDIR /src | ||
| ARG PKG_REPO | ||
| RUN git init . && git remote add origin "${PKG_REPO}" | ||
| ARG PKG_REF | ||
| RUN git fetch origin "${PKG_REF}" +refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/* && git checkout -q FETCH_HEAD | ||
|
|
||
| FROM src-base AS src-tgz | ||
| RUN --mount=from=src,source=/src,target=/model \ | ||
| mkdir /out && tar -C / -zcf /out/model.tgz --exclude .git model | ||
|
|
||
| # metadata | ||
| FROM src-base AS metadata-builder | ||
| ARG PKG_REPO | ||
| ARG PKG_REF | ||
| ARG NIGHTLY_BUILD | ||
| RUN --mount=type=bind,from=scripts,source=gen-ver.sh,target=/usr/local/bin/gen-ver \ | ||
| --mount=type=bind,from=src,source=/src,target=/src <<EOT | ||
| set -e | ||
| mkdir -p /out | ||
| for l in $(gen-ver "/src"); do | ||
| export "${l?}" | ||
| done | ||
| cat > "/out/metadata.env" <<-EOF | ||
| REPO=${PKG_REPO%.*} | ||
| REF=${PKG_REF} | ||
| VERSION=${GENVER_VERSION} | ||
| COMMIT=${GENVER_COMMIT} | ||
| EOF | ||
| EOT | ||
|
|
||
| FROM scratch AS metadata | ||
| COPY --from=metadata-builder /out / | ||
|
|
||
| # deb | ||
| FROM ${DISTRO_IMAGE} AS builder-deb | ||
| COPY --from=xx / / | ||
| ARG DEBIAN_FRONTEND | ||
| ENV GOPROXY="https://proxy.golang.org|direct" | ||
| ENV GOPATH="/go" | ||
| ENV PATH="$PATH:/usr/local/go/bin:$GOPATH/bin" | ||
| ENV GOTOOLCHAIN="local" | ||
| ENV GO111MODULE="on" | ||
| ENV CGO_ENABLED="0" | ||
| ARG DISTRO_NAME | ||
| RUN apt-get update && apt-get install -y --no-install-recommends apt-utils bash ca-certificates curl devscripts equivs git | ||
| COPY deb /root/package/debian | ||
| ARG TARGETPLATFORM | ||
| RUN mk-build-deps -t "xx-apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i /root/package/debian/control | ||
| WORKDIR /root/package | ||
| ARG NIGHTLY_BUILD | ||
| ARG DISTRO_RELEASE | ||
| ARG DISTRO_ID | ||
| ARG DISTRO_SUITE | ||
| ARG PKG_NAME | ||
| ARG PKG_REF | ||
| ARG PKG_PACKAGER | ||
| ARG PKG_DEB_BUILDFLAGS | ||
| ARG PKG_DEB_REVISION | ||
| ARG PKG_DEB_EPOCH | ||
| ARG SOURCE_DATE_EPOCH | ||
| RUN --mount=type=bind,source=scripts/pkg-deb-build.sh,target=/usr/local/bin/pkg-deb-build \ | ||
| --mount=type=bind,from=scripts,source=gen-ver.sh,target=/usr/local/bin/gen-ver \ | ||
| --mount=type=bind,from=scripts,source=gen-deb-changelog.sh,target=/usr/local/bin/gen-deb-changelog \ | ||
| --mount=type=bind,from=scripts,source=fix-cc.sh,target=/usr/local/bin/fix-cc \ | ||
| --mount=type=bind,from=src,source=/src,target=/root/package/model,rw \ | ||
| --mount=type=bind,from=go,source=/usr/local/go,target=/usr/local/go \ | ||
| OUTDIR=/out SRCDIR=./model pkg-deb-build | ||
|
|
||
| # rpm | ||
| FROM ${DISTRO_IMAGE} AS builder-rpm | ||
| COPY --from=xx / / | ||
| ENV GOPROXY="https://proxy.golang.org|direct" | ||
| ENV GOPATH="/go" | ||
| ENV PATH="$PATH:/usr/local/go/bin:$GOPATH/bin" | ||
| ENV GOTOOLCHAIN="local" | ||
| ENV GO111MODULE="on" | ||
| ENV CGO_ENABLED="0" | ||
| ARG DISTRO_NAME | ||
| RUN --mount=type=bind,from=scripts,source=rpm-init.sh,target=/usr/local/bin/rpm-init \ | ||
| rpm-init $DISTRO_NAME | ||
| COPY rpm /root/rpmbuild/SPECS | ||
| ARG TARGETPLATFORM | ||
| RUN --mount=type=bind,from=scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \ | ||
| rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS | ||
| WORKDIR /root/rpmbuild | ||
| ARG NIGHTLY_BUILD | ||
| ARG DISTRO_RELEASE | ||
| ARG DISTRO_ID | ||
| ARG DISTRO_SUITE | ||
| ARG PKG_NAME | ||
| ARG PKG_REF | ||
| ARG PKG_PACKAGER | ||
| ARG PKG_RPM_BUILDFLAGS | ||
| ARG PKG_RPM_RELEASE | ||
| ARG SOURCE_DATE_EPOCH | ||
| RUN --mount=type=bind,source=scripts/pkg-rpm-build.sh,target=/usr/local/bin/pkg-rpm-build \ | ||
| --mount=type=bind,from=scripts,source=gen-ver.sh,target=/usr/local/bin/gen-ver \ | ||
| --mount=type=bind,from=scripts,source=fix-cc.sh,target=/usr/local/bin/fix-cc \ | ||
| --mount=type=bind,from=src-tgz,source=/out/model.tgz,target=/root/rpmbuild/SOURCES/model.tgz \ | ||
| --mount=type=bind,from=src,source=/src,target=/usr/local/src/model \ | ||
| --mount=type=bind,from=go,source=/usr/local/go,target=/usr/local/go \ | ||
| OUTDIR=/out SRCDIR=/usr/local/src/model pkg-rpm-build | ||
|
|
||
| # static | ||
| FROM --platform=$BUILDPLATFORM ${DISTRO_IMAGE} AS builder-static | ||
| COPY --from=xx / / | ||
| ARG DEBIAN_FRONTEND | ||
| RUN apt-get update && apt-get install -y --no-install-recommends bash ca-certificates file git zip tar | ||
| ENV GOPROXY="https://proxy.golang.org|direct" | ||
| ENV GOPATH="/go" | ||
| ENV PATH="$PATH:/usr/local/go/bin:$GOPATH/bin" | ||
| ENV GOTOOLCHAIN="local" | ||
| ENV GO111MODULE="on" | ||
| ENV CGO_ENABLED="0" | ||
| ARG PKG_NAME | ||
| ARG PKG_REF | ||
| ARG NIGHTLY_BUILD | ||
| WORKDIR /build | ||
| ARG TARGETPLATFORM | ||
| RUN --mount=type=bind,source=scripts/pkg-static-build.sh,target=/usr/local/bin/pkg-static-build \ | ||
| --mount=type=bind,from=scripts,source=gen-ver.sh,target=/usr/local/bin/gen-ver \ | ||
| --mount=type=bind,from=scripts,source=fix-cc.sh,target=/usr/local/bin/fix-cc \ | ||
| --mount=type=bind,from=src,source=/src,target=/usr/local/src/model \ | ||
| --mount=type=bind,from=gocross,source=/usr/local/go,target=/usr/local/go,rw \ | ||
| OUTDIR=/out BUILDDIR=/build SRCDIR=/usr/local/src/model pkg-static-build | ||
|
|
||
| FROM builder-${DISTRO_TYPE} AS build-pkg | ||
| ARG BUILDKIT_SBOM_SCAN_STAGE=true | ||
|
|
||
| FROM scratch AS pkg | ||
| COPY --from=build-pkg /out / |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| Source: docker-model-plugin | ||
| Section: admin | ||
| Priority: optional | ||
| Maintainer: Docker <support@docker.com> | ||
| Homepage: https://www.docker.com | ||
| Vcs-Browser: https://github.com/docker/model-cli | ||
| Vcs-Git: git://github.com/docker/model-cli.git | ||
| Standards-Version: 3.9.6 | ||
| Build-Depends: bash, | ||
| debhelper-compat (= 12), | ||
| make | ||
|
|
||
| Package: docker-model-plugin | ||
| Priority: optional | ||
| Architecture: linux-any | ||
| Enhances: docker-ce-cli | ||
| Description: Docker Model Runner plugin for the Docker CLI. | ||
| . | ||
| This plugin provides the 'docker model' subcommand. | ||
| Homepage: https://docs.docker.com/model-runner/ |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #!/usr/bin/make -f | ||
|
|
||
| # force packages to be built with xz compression, as Ubuntu 21.10 and up use | ||
| # zstd compression, which is non-standard, and breaks 'dpkg-sig --verify' | ||
| override_dh_builddeb: | ||
| dh_builddeb -- -Zxz | ||
|
|
||
| override_dh_auto_build: | ||
| mkdir -p /usr/libexec/docker/cli-plugins && \ | ||
| GO111MODULE=on make -C $(CURDIR)/model VERSION=$(VERSION) ce-release \ | ||
| && mv $(CURDIR)/model/dist/docker-model /usr/libexec/docker/cli-plugins/docker-model | ||
|
|
||
| override_dh_auto_test: | ||
| ver="$$(/usr/libexec/docker/cli-plugins/docker-model docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $$1 == "Version" { print $$2 }')"; \ | ||
| test "$$ver" = "$(VERSION)" && echo "PASS: docker-model version OK" || (echo "FAIL: docker-model version ($$ver) did not match" && exit 1) | ||
|
|
||
| override_dh_strip: | ||
| # Go has lots of problems with stripping, so just don't | ||
|
|
||
| # http://manpages.debian.org/dh_dwz | ||
| override_dh_dwz: | ||
| # dh_dwz in debhelper versions less than 13 has issues with files that are missing debug symbols (once we update to debhelper-compat 13+ this can be removed) | ||
| @# https://packages.debian.org/debhelper | ||
| @# https://packages.ubuntu.com/debhelper | ||
|
|
||
| override_dh_auto_install: | ||
| install -D -p -m 0755 /usr/libexec/docker/cli-plugins/docker-model debian/docker-model-plugin/usr/libexec/docker/cli-plugins/docker-model | ||
|
|
||
| override_dh_installinit: | ||
| dh_installinit | ||
|
|
||
| override_dh_shlibdeps: | ||
| dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info | ||
|
|
||
| override_dh_install: | ||
| dh_install | ||
|
|
||
| override_dh_gencontrol: | ||
| dh_gencontrol --remaining-packages | ||
|
|
||
| %: | ||
| dh $@ |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 1.0 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like upstream doesn't have a Dockerfile, other than for generating the docs; should we add one there as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think they should have one. At least they should pin Go version, atm it always takes latest, see docker/model-cli#62 (comment)