Skip to content

Commit c0f1c4e

Browse files
authored
feat: enhance containerfile / adding minimal image (#499)
Signed-off-by: SequeI <[email protected]>
1 parent 997395a commit c0f1c4e

File tree

3 files changed

+87
-24
lines changed

3 files changed

+87
-24
lines changed

.github/workflows/release.yml

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,44 +75,80 @@ jobs:
7575
with:
7676
persist-credentials: false
7777

78-
- name: Build Image
79-
id: build_image
78+
- name: Login to GitHub Container Registry
79+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
80+
id: registry_login
81+
with:
82+
registry: ghcr.io
83+
username: ${{ github.actor }}
84+
password: ${{ secrets.GITHUB_TOKEN }}
85+
86+
- name: Build minimal image
87+
id: build_minimal_image
8088
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2.13
8189
with:
8290
containerfiles: |
8391
./Containerfile
84-
image: ghcr.io/sigstore/model-transparency-cli
85-
tags: "latest ${{ github.event.release.tag_name }}"
92+
image: sigstore/model-transparency-cli
93+
tags: "${{ github.event.release.tag_name }}-minimal"
8694
archs: amd64
8795
oci: false
96+
build-args: |
97+
BUILD_TYPE=minimal
8898
89-
- id: docker_meta
99+
- id: docker_meta_minimal
90100
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
91101
with:
92-
images: ${{ steps.build_image.outputs.image }}
102+
images: ${{ steps.build_minimal_image.outputs.image }}
93103
tags: type=sha,format=long,type=ref,event=branch
94104

95-
- name: Login to GitHub Container Registry
96-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
97-
id: registry_login
105+
- name: Push minimal image to GHCR
106+
uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c # v2.8
107+
id: push_minimal
98108
with:
109+
image: ${{ steps.build_minimal_image.outputs.image }}
110+
tags: ${{ steps.build_minimal_image.outputs.tags }}
99111
registry: ghcr.io
100-
username: ${{ github.actor }}
101-
password: ${{ secrets.GITHUB_TOKEN }}
102112

103-
- name: Push To GHCR
113+
- name: Generate artifact attestation
114+
uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2.4.0
115+
with:
116+
subject-name: ghcr.io/sigstore/model-transparency-cli
117+
subject-digest: ${{ steps.push_minimal.outputs.digest }}
118+
push-to-registry: true
119+
120+
- name: Build full image
121+
id: build_full_image
122+
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2.13
123+
with:
124+
containerfiles: |
125+
./Containerfile
126+
image: sigstore/model-transparency-cli
127+
tags: "latest ${{ github.event.release.tag_name }}"
128+
archs: amd64
129+
oci: false
130+
build-args: |
131+
BUILD_TYPE=full
132+
133+
- id: docker_meta_full
134+
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
135+
with:
136+
images: ${{ steps.build_full_image.outputs.image }}
137+
tags: type=sha,format=long,type=ref,event=branch
138+
139+
- name: Push full image to GHCR
104140
uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c # v2.8
105-
id: push
141+
id: push_full
106142
with:
107-
image: ${{ steps.build_image.outputs.image }}
108-
tags: ${{ steps.build_image.outputs.tags }}
143+
image: ${{ steps.build_full_image.outputs.image }}
144+
tags: ${{ steps.build_full_image.outputs.tags }}
109145
registry: ghcr.io
110146

111147
- name: Generate artifact attestation
112148
uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2.4.0
113149
with:
114150
subject-name: ghcr.io/sigstore/model-transparency-cli
115-
subject-digest: ${{ steps.push.outputs.digest }}
151+
subject-digest: ${{ steps.push_full.outputs.digest }}
116152
push-to-registry: true
117153

118154
# TODO: Create and publish release notes

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ All versions prior to 1.0.0 are untracked.
2626
- Added guidance to `README.md` on how to install `model-signing` with PKCS#11 support.
2727
- Added support trace sigstore sign and verify operations using OpenTelemetry.
2828
- cli: Added support for `--ignore_unsigned_files` option
29+
- Implemented a new, minimal container image. This variant excludes optional dependencies (like OTel and PKCS#11) to reduce footprint, focusing solely on core signing and verification mechanisms.
2930

3031
## [1.0.1] - 2024-04-18
3132

Containerfile

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 The Sigstore Authors
1+
# Copyright 2025 The Sigstore Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,17 +12,43 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""For the stable high-level API, see model_signing.api."""
15+
# Default
16+
ARG BUILD_TYPE=minimal
1617

17-
__version__ = "0.1.1"
18+
FROM python:3.13-slim AS base_builder
1819

19-
FROM python:3.13-slim
20+
RUN apt-get update && \
21+
apt-get install -y --no-install-recommends \
22+
g++ \
23+
swig
2024

21-
COPY pyproject.toml ./
22-
COPY src ./src
25+
FROM base_builder AS minimal_install
26+
WORKDIR /app
27+
COPY . /app
28+
RUN pip install .
2329

24-
RUN python -m pip install model_signing
30+
FROM base_builder AS full_install
31+
WORKDIR /app
32+
COPY . /app
33+
RUN pip install .[pkcs11,otel]
2534

26-
ENTRYPOINT ["/usr/local/bin/model_signing"]
35+
FROM python:3.13-slim AS minimal_image
36+
COPY --from=minimal_install /usr/local/bin /usr/local/bin
37+
COPY --from=minimal_install /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages
2738

39+
FROM python:3.13-slim AS full_image
40+
COPY --from=full_install /usr/local/bin /usr/local/bin
41+
COPY --from=full_install /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages
42+
43+
FROM ${BUILD_TYPE}_image AS final_image
44+
45+
ENTRYPOINT ["model_signing"]
2846
CMD ["--help"]
47+
48+
ARG APP_VERSION="1.0.1"
49+
50+
LABEL org.opencontainers.image.title="Model Transparency Library" \
51+
org.opencontainers.image.description="Supply chain security for ML" \
52+
org.opencontainers.image.version="$APP_VERSION" \
53+
org.opencontainers.image.authors="The Sigstore Authors <[email protected]>" \
54+
org.opencontainers.image.licenses="Apache-2.0" \

0 commit comments

Comments
 (0)