Skip to content

Commit 8496fc1

Browse files
authored
Feat/sp 2021 add multiple images (#88)
* adding multi-image build
1 parent a98bf2a commit 8496fc1

File tree

6 files changed

+80
-18
lines changed

6 files changed

+80
-18
lines changed

.github/workflows/container-local-test.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
- 'main'
1212

1313
env:
14+
IMAGE_BASE: scanoss/scanoss-py-base
1415
IMAGE_NAME: scanoss/scanoss-py
1516

1617
jobs:
@@ -38,17 +39,35 @@ jobs:
3839
- name: Setup Docker buildx
3940
uses: docker/setup-buildx-action@v3
4041

41-
# Build Docker image with Buildx
42-
- name: Build Docker Image
43-
id: build-and-push
42+
# Build Docker image with Buildx - Base
43+
- name: Build Docker Image - No Entrypoint
44+
id: build-no-ep
45+
uses: docker/build-push-action@v5
46+
with:
47+
context: .
48+
push: false
49+
tags: ${{ env.IMAGE_BASE }}:latest
50+
target: no_entry_point
51+
outputs: type=docker,dest=/tmp/scanoss-py-base.tar
52+
53+
# Build Docker image with Buildx - Entrypoint
54+
- name: Build Docker Image - With Entrypoint
55+
id: build-with-ep
4456
uses: docker/build-push-action@v5
4557
with:
4658
context: .
4759
push: false
4860
tags: ${{ env.IMAGE_NAME }}:latest
61+
target: with_entry_point
4962
outputs: type=docker,dest=/tmp/scanoss-py.tar
5063

51-
- name: Test Docker Image
64+
- name: Test Docker Image - No Entrypoint
65+
run: |
66+
docker load --input /tmp/scanoss-py-base.tar
67+
docker image ls -a
68+
docker run ${{ env.IMAGE_BASE }} scanoss-py version
69+
70+
- name: Test Docker Image - With Entrypoint
5271
run: |
5372
docker load --input /tmp/scanoss-py.tar
5473
docker image ls -a

.github/workflows/container-publish-ghcr.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99

1010
env:
1111
REGISTRY: ghcr.io
12+
IMAGE_NAME_BASE: scanoss/scanoss-py-base
1213
IMAGE_NAME: scanoss/scanoss-py
1314

1415
jobs:
@@ -56,14 +57,36 @@ jobs:
5657
password: ${{ secrets.GITHUB_TOKEN }}
5758

5859
# Extract metadata (tags, labels) for Docker
59-
- name: Extract Docker metadata
60+
- name: Extract Docker metadata - no entrypoint
61+
id: meta-ne
62+
uses: docker/metadata-action@v4
63+
with:
64+
images: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BASE }}"
65+
66+
# Build and push Docker image with Buildx (don't push on PR)
67+
- name: Build and push Docker image - Base (no entrypoint)
68+
id: build-and-push-ne
69+
uses: docker/build-push-action@v5
70+
with:
71+
context: .
72+
push: ${{ github.event_name != 'pull_request' }}
73+
tags: ${{ steps.meta-ne.outputs.tags }}
74+
labels: ${{ steps.meta-ne.outputs.labels }}
75+
platforms: linux/amd64,linux/arm64
76+
cache-from: type=gha
77+
cache-to: type=gha,mode=max
78+
provenance: false
79+
target: no_entry_point
80+
81+
# Extract metadata (tags, labels) for Docker
82+
- name: Extract Docker metadata - entrypoint
6083
id: meta
6184
uses: docker/metadata-action@v4
6285
with:
6386
images: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
6487

6588
# Build and push Docker image with Buildx (don't push on PR)
66-
- name: Build and push Docker image
89+
- name: Build and push Docker image - EP (entrypoint)
6790
id: build-and-push
6891
uses: docker/build-push-action@v5
6992
with:
@@ -75,6 +98,7 @@ jobs:
7598
cache-from: type=gha
7699
cache-to: type=gha,mode=max
77100
provenance: false
101+
target: with_entry_point
78102

79103
# Test the docker image
80104
- name: Test Published Image

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- Upcoming changes...
1111

12+
## [1.19.2] - 2025-01-06
13+
### Added
14+
- Add second container image `scanoss-py-base` with no `ENTRYPOINT`
15+
- This is useful for calls from container pipelines (i.e. Jenkins)
16+
1217
## [1.19.1] - 2025-01-06
1318
### Fixed
1419
- Fixed undeclared components inspection
@@ -423,4 +428,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
423428
[1.18.0]: https://github.com/scanoss/scanoss.py/compare/v1.17.5...v1.18.0
424429
[1.18.1]: https://github.com/scanoss/scanoss.py/compare/v1.18.0...v1.18.1
425430
[1.19.0]: https://github.com/scanoss/scanoss.py/compare/v1.18.1...v1.19.0
426-
[1.19.1]: https://github.com/scanoss/scanoss.py/compare/v1.19.0...v1.19.1
431+
[1.19.1]: https://github.com/scanoss/scanoss.py/compare/v1.19.0...v1.19.1
432+
[1.19.2]: https://github.com/scanoss/scanoss.py/compare/v1.19.1...v1.19.2

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ RUN tar -xvzf /install/v5.39.210212.tar.gz -C /install \
3737
RUN rm -rf /root/.local/lib/python3.10/site-packages/licensedcode/data/rules /root/.local/lib/python3.10/site-packages/licensedcode/data/cache
3838
RUN mkdir /root/.local/lib/python3.10/site-packages/licensedcode/data/rules /root/.local/lib/python3.10/site-packages/licensedcode/data/cache
3939

40-
FROM base
40+
FROM base AS no_entry_point
4141

4242
# Copy the Python user packages from the build image to here
4343
COPY --from=builder /root/.local /root/.local
@@ -56,5 +56,7 @@ WORKDIR /scanoss
5656
# Run scancode once to setup any initial files, etc. so that it'll run faster later
5757
RUN scancode -p --only-findings --quiet --json /scanoss/scancode-dependencies.json /scanoss && rm -f /scanoss/scancode-dependencies.json
5858

59+
FROM no_entry_point AS with_entry_point
60+
5961
ENTRYPOINT ["scanoss-py"]
6062
CMD ["--help"]

Makefile

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11

22
#vars
3+
IMAGE_BASE=scanoss-py-base
34
IMAGE_NAME=scanoss-py
45
REPO=scanoss
6+
DOCKER_FULLNAME_BASE=${REPO}/${IMAGE_BASE}
57
DOCKER_FULLNAME=${REPO}/${IMAGE_NAME}
8+
GHCR_FULLNAME_BASE=ghcr.io/${REPO}/${IMAGE_BASE}
69
GHCR_FULLNAME=ghcr.io/${REPO}/${IMAGE_NAME}
710
VERSION=$(shell ./version.py)
811

@@ -55,15 +58,19 @@ package_all: dist publish ## Build & Publish Python package to PyPI
5558

5659
ghcr_build: dist ## Build GitHub container image with local arch
5760
@echo "Building GHCR container image..."
58-
docker build -t $(GHCR_FULLNAME) .
61+
docker build --target with_entry_point -t $(GHCR_FULLNAME) .
62+
63+
ghcr_build_base: dist ## Build GitHub container base image with local arch (no entrypoint)
64+
@echo "Building GHCR base container image..."
65+
docker build --target no_entry_point -t $(GHCR_FULLNAME_BASE) .
5966

6067
ghcr_amd64: dist ## Build GitHub AMD64 container image
6168
@echo "Building GHCR AMD64 container image..."
62-
docker build -t $(GHCR_FULLNAME) --platform linux/amd64 .
69+
docker build --target with_entry_point -t $(GHCR_FULLNAME) --platform linux/amd64 .
6370

6471
ghcr_arm64: dist ## Build GitHub ARM64 container image
6572
@echo "Building GHCR ARM64 container image..."
66-
docker build -t $(GHCR_FULLNAME) --platform linux/arm64 .
73+
docker build --target with_entry_point -t $(GHCR_FULLNAME) --platform linux/arm64 .
6774

6875
ghcr_tag: ## Tag the latest GH container image with the version from Python
6976
@echo "Tagging GHCR latest image with $(VERSION)..."
@@ -76,21 +83,25 @@ ghcr_push: ## Push the GH container image to GH Packages
7683

7784
ghcr_release: dist ## Build/Publish GitHub multi-platform container image
7885
@echo "Building & Releasing GHCR multi-platform container image $(VERSION)..."
79-
docker buildx build --push -t $(GHCR_FULLNAME):$(VERSION) --platform linux/arm64,linux/amd64 .
86+
docker buildx build --push --target with_entry_point -t $(GHCR_FULLNAME):$(VERSION) --platform linux/arm64,linux/amd64 .
8087

8188
ghcr_all: ghcr_release ## Execute all GHCR container actions
8289

83-
docker_build: ## Build Docker container image with local arch
90+
docker_build: dist ## Build Docker container image with local arch
91+
@echo "Building Docker image..."
92+
docker build --no-cache --target with_entry_point -t $(DOCKER_FULLNAME) .
93+
94+
docker_build_base: dist ## Build Docker container image with local arch
8495
@echo "Building Docker image..."
85-
docker build --no-cache -t $(DOCKER_FULLNAME) .
96+
docker build --no-cache --target no_entry_point -t $(DOCKER_FULLNAME_BASE) .
8697

8798
docker_amd64: dist ## Build Docker AMD64 container image
8899
@echo "Building Docker AMD64 container image..."
89-
docker build -t $(DOCKER_FULLNAME) --platform linux/amd64 .
100+
docker build --target with_entry_point -t $(DOCKER_FULLNAME) --platform linux/amd64 .
90101

91102
docker_arm64: dist ## Build Docker ARM64 container image
92103
@echo "Building Docker ARM64 container image..."
93-
docker build -t $(DOCKER_FULLNAME) --platform linux/arm64 .
104+
docker build --target with_entry_point -t $(DOCKER_FULLNAME) --platform linux/arm64 .
94105

95106
docker_tag: ## Tag the latest Docker container image with the version from Python
96107
@echo "Tagging Docker latest image with $(VERSION)..."
@@ -103,6 +114,6 @@ docker_push: ## Push the Docker container image to DockerHub
103114

104115
docker_release: dist ## Build/Publish Docker multi-platform container image
105116
@echo "Building & Releasing Docker multi-platform container image $(VERSION)..."
106-
docker buildx build --push -t $(DOCKER_FULLNAME):$(VERSION) --platform linux/arm64,linux/amd64 .
117+
docker buildx build --push --target with_entry_point -t $(DOCKER_FULLNAME):$(VERSION) --platform linux/arm64,linux/amd64 .
107118

108119
docker_all: docker_release ## Execute all DockerHub container actions

src/scanoss/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
THE SOFTWARE.
2323
"""
2424

25-
__version__ = "1.19.1"
25+
__version__ = "1.19.2"

0 commit comments

Comments
 (0)