Skip to content

Commit db3ceef

Browse files
authored
Merge pull request #2265 from daniel-eder/feature/dockerfile
Add Dockerfile to build docker image from ScanCode sources Signed-off-by: Ayan Sinha Mahapatra <[email protected]> Signed-off-by: Philippe Ombredanne <[email protected]>
2 parents 302309b + 05933ed commit db3ceef

File tree

6 files changed

+115
-3
lines changed

6 files changed

+115
-3
lines changed

.dockerignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Ignore the Docker files themselves to avoid that all layers are invalidated if the Docker files are changed during development.
2+
.dockerignore
3+
Dockerfile
4+
5+
# Ignore the Git directory and files and github directory.
6+
.git/
7+
.github/
8+
.gitattributes
9+
.gitignore
10+
11+
# Ignore other directories that are not required in the image
12+
tests/
13+
docs/
14+
samples/

AUTHORS.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ The following organizations or individuals have contributed to ScanCode:
2121
- Gaurang Rao @Gaupeng
2222
- Tushar Goel @TG1999
2323
- Richard Menzies @WizardOhio24
24-
24+
- Daniel Eder @daniel-eder

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ v3.2.2rc3 (2020-09-21)
88
Internal code changes:
99

1010
- Ensure commoncode ccan become a standalone package #2233
11-
-
11+
- Add Dockerfile to build docker image from ScanCode sources #2265
1212

1313

1414
v3.2.1rc2 (2020-09-11)

Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#
2+
# Copyright (c) 2018 nexB Inc. and others. All rights reserved.
3+
# http://nexb.com and https://github.com/nexB/scancode-toolkit/
4+
# The ScanCode software is licensed under the Apache License version 2.0.
5+
# Data generated with ScanCode require an acknowledgment.
6+
# ScanCode is a trademark of nexB Inc.
7+
#
8+
# You may not use this software except in compliance with the License.
9+
# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0
10+
# Unless required by applicable law or agreed to in writing, software distributed
11+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
13+
# specific language governing permissions and limitations under the License.
14+
#
15+
# When you publish or redistribute any data created with ScanCode or any ScanCode
16+
# derivative work, you must accompany this data with the following acknowledgment:
17+
#
18+
# Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES
19+
# OR CONDITIONS OF ANY KIND, either express or implied. No content created from
20+
# ScanCode should be considered or used as legal advice. Consult an Attorney
21+
# for any legal advice.
22+
# ScanCode is a free software code scanning tool from nexB Inc. and others.
23+
# Visit https://github.com/nexB/scancode-toolkit/ for support and download.
24+
25+
FROM python:3.6
26+
27+
# Requirements as per https://scancode-toolkit.readthedocs.io/en/latest/getting-started/install.html
28+
RUN apt-get update && apt-get install bzip2 xz-utils zlib1g libxml2-dev libxslt1-dev
29+
30+
# Create directory for scancode sources
31+
RUN mkdir scancode-toolkit
32+
33+
# Copy sources into docker container
34+
COPY . scancode-toolkit
35+
36+
# Set workdir
37+
WORKDIR scancode-toolkit
38+
39+
# Run scancode once for initial configuration, with --reindex-licenses to create the base license index
40+
RUN ./scancode --reindex-licenses
41+
42+
# Add scancode to path
43+
ENV PATH=$HOME/scancode-toolkit:$PATH
44+
45+
# Set entrypoint to be the scancode command, allows to run the generated docker image directly with the scancode arguments: `docker run (...) <containername> <scancode arguments>`
46+
ENTRYPOINT ["./scancode"]

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ refers to installing the required Python interpreter (Python 3.6 is recommended)
9494
There are 3 main ways you can `install ScanCode <https://scancode-toolkit.readthedocs.io/en/latest/getting-started/install.html>`_.
9595

9696
- `Installation as an Application: Downloading Releases <https://scancode-toolkit.readthedocs.io/en/latest/getting-started/install.html#installation-as-an-application-downloading-releases>`_ *(Recommended)*
97+
- `Installation via Docker: via pip <https://scancode-toolkit.readthedocs.io/en/latest/getting-started/install.html#installation-via-docker>`_
9798
- `Installation from Source Code: Git Clone <https://scancode-toolkit.readthedocs.io/en/latest/getting-started/install.html#installation-from-source-code-git-clone>`_
9899
- `Installation as a library: via pip <https://scancode-toolkit.readthedocs.io/en/latest/getting-started/install.html#pip-install>`_
99100

docs/source/getting-started/install.rst

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
Comprehensive Installation
22
==========================
33

4-
There are 3 main ways you can install ScanCode.
4+
There are 4 main ways you can install ScanCode.
55

66
- :ref:`app_install`
77

88
The recommended method for installing ScanCode is Downloading the latest release as an
99
application and then configure and use directly. This is easy because no knowledge of pip/git
1010
or other developer tools is necessary.
1111

12+
- :ref:`docker_install`
13+
14+
An alternative to installing the latest Scancode Toolkit release natively is to build
15+
a Docker image from the included Dockerfile. This is easy because the only prerequisite
16+
is a working Docker installation.
17+
1218
- :ref:`source_code_install`
1319

1420
You can download/clone the source code repository via git/GitHub and then run a configure script
@@ -234,6 +240,51 @@ Un-installation
234240

235241
----
236242

243+
.. _docker_install:
244+
245+
Installation via Docker:
246+
------------------------
247+
248+
You can install Scancode Toolkit by building a Docker image from the included Dockerfile.
249+
250+
Download the ScanCode-Toolkit Source Code
251+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
252+
253+
- Either download the Source Code for one of the releases ( :ref:`app_install` ) and unzip it.
254+
- Or git clone the latest ( :ref:`source_code_install` ) Source Code.
255+
256+
257+
Build the Docker image
258+
^^^^^^^^^^^^^^^^^^^^^^
259+
260+
The ``docker build`` command needs to run in the directory of the source code,
261+
make sure to ``cd`` into the correct directory.
262+
263+
cd scancode-toolkit
264+
docker build -t scancode-toolkit .
265+
266+
Run using Docker
267+
^^^^^^^^^^^^^^^^
268+
269+
The docker image will forward all arguments it receives directly to the ``scancode`` command.
270+
271+
Display help:
272+
273+
docker run scancode-toolkit --help
274+
275+
Mount current working directory and run scan on mounted folder:
276+
277+
docker run -v $PWD/:/project scancode-toolkit -clpeui --json-pp /project/result.json /project
278+
279+
This will mount your current working from the host into ``/project`` in the container
280+
and then scan the contents. The output ``result.json`` will be written back to your
281+
corrent working directory on the host.
282+
283+
Note that the parameters *before* ``scancode-toolkit`` are used for docker,
284+
those after will be forwarded to scancode.
285+
286+
----
287+
237288
.. _source_code_install:
238289

239290
Installation from Source Code: Git Clone

0 commit comments

Comments
 (0)