Skip to content

Commit 73a1452

Browse files
committed
Make the Dockerfile work #2554 #2762
The dockerfile is now updated with the latest approach and is tested to work. Reference: #2762 Reference: #2554 Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent cb86166 commit 73a1452

File tree

3 files changed

+47
-23
lines changed

3 files changed

+47
-23
lines changed

.dockerignore

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,16 @@ Dockerfile
1111
# Ignore other directories that are not required in the image
1212
tests/
1313
docs/
14-
samples/
14+
samples/
15+
venv/
16+
tmp/
17+
.cache/
18+
.pytest_cache/
19+
.settings/
20+
docs/
21+
build/
22+
dist/
23+
24+
# generated files
25+
**/*.pyc
26+
src/licensedcode/data/cache/license_index/index_cache

Dockerfile

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,43 @@
77
# See https://aboutcode.org for more information about nexB OSS projects.
88
#
99

10-
FROM python:3.8-slim-buster
10+
FROM --platform=linux/amd64 python:3.8-slim-buster
1111

12-
# Requirements as per https://scancode-toolkit.readthedocs.io/en/latest/getting-started/install.html
12+
# Python settings: Force unbuffered stdout and stderr (i.e. they are flushed to terminal immediately)
13+
ENV PYTHONUNBUFFERED 1
14+
# Python settings: do not write pyc files
15+
ENV PYTHONDONTWRITEBYTECODE 1
16+
17+
# OS requirements as per
18+
# https://scancode-toolkit.readthedocs.io/en/latest/getting-started/install.html
1319
RUN apt-get update \
14-
&& apt-get install -y bzip2 xz-utils zlib1g libxml2-dev libxslt1-dev libgomp1 libpopt0\
20+
&& apt-get install -y --no-install-recommends \
21+
bzip2 \
22+
xz-utils \
23+
zlib1g \
24+
libxml2-dev \
25+
libxslt1-dev \
26+
libgomp1 \
27+
libsqlite3-0 \
28+
libgcrypt20 \
29+
libpopt0 \
30+
libzstd1 \
1531
&& apt-get clean \
1632
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
1733

1834
# Create directory for scancode sources
19-
RUN mkdir scancode-toolkit
35+
WORKDIR /scancode-toolkit
2036

2137
# Copy sources into docker container
22-
COPY . scancode-toolkit
23-
24-
# Set workdir
25-
WORKDIR scancode-toolkit
38+
COPY . /scancode-toolkit
2639

27-
# Run scancode once for initial configuration, with --reindex-licenses to create the base license index
40+
# Run scancode once for initial configuration, with
41+
# --reindex-licenses to create the base license index
2842
RUN ./scancode --reindex-licenses
2943

3044
# Add scancode to path
31-
ENV PATH=$HOME/scancode-toolkit:$PATH
45+
ENV PATH=/scancode-toolkit:$PATH
3246

33-
# Set entrypoint to be the scancode command, allows to run the generated docker image directly with the scancode arguments: `docker run (...) <containername> <scancode arguments>`
47+
# Set entrypoint to be the scancode command, allows to run the generated docker
48+
# image directly with the scancode arguments: `docker run (...) <containername> <scancode arguments>`
3449
ENTRYPOINT ["./scancode"]

docs/source/getting-started/install.rst

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ System Requirements
5454
#. Mac: on recent x86 64-bit macOS (10.15 and up, including 11 and 12),
5555
Use the X86 emulation mode on Apple ARM M1 CPUs.
5656
#. Windows: on Windows 10 and up,
57-
#. FreeBSD,
57+
#. FreeBSD.
5858

5959

6060
.. _install_prerequisites:
@@ -98,7 +98,6 @@ ScanCode needs a Python 3.7+ interpreter; We support all Python versions from
9898
Alternativelu you can download and install Python 3.8 from https://www.python.org/
9999

100100

101-
102101
- **On Windows**:
103102

104103
Download and install Python 3.8 from https://www.python.org/
@@ -230,20 +229,17 @@ The prerequisite is a working `docker installation <https://docs.docker.com/engi
230229
Download the ScanCode-Toolkit Source Code
231230
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
232231

233-
- Either download the Source Code for one of the releases ( :ref:`app_install` )
234-
and unzip it.
235-
- Or ``git clone https://github.com/nexB/scancode-toolkit`` to get the latest
236-
( :ref:`source_code_install` ) Source Code.
232+
- ``git clone https://github.com/nexB/scancode-toolkit`` to get the latest
233+
( :ref:`source_code_install` ) source code.
237234

238235

239236
Build the Docker image
240237
^^^^^^^^^^^^^^^^^^^^^^
241238

242-
The ``docker build`` command needs to run in the directory of the source code,
243-
make sure to ``cd`` into the correct directory.::
239+
Run the ``docker build`` source code checkout directory.::
244240

245241
cd scancode-toolkit
246-
docker build -t scancode-toolkit .
242+
docker build --tag scancode-toolkit --tag scancode-toolkit:$(git describe --tags) .
247243

248244

249245
Run using Docker
@@ -255,9 +251,10 @@ Display help::
255251

256252
docker run scancode-toolkit --help
257253

258-
Mount current working directory and run scan on this mounted folder::
254+
Mount current working directory as "/project" and run a scan on a file name apache-2.0.LICENSE directory.
255+
The JSON results will be in scan-result.json::
259256

260-
docker run -v $PWD/:/project scancode-toolkit -clipeu --json-pp /project/result.json /project
257+
docker run -v $PWD/:/project scancode-toolkit -clipeu --json-pp /project/scan-result.json /project/apache-2.0.LICENSE
261258

262259
This will mount your current working from the host into ``/project`` in the container
263260
and then scan the contents. The output ``result.json`` will be written back to your

0 commit comments

Comments
 (0)