Skip to content

Commit

Permalink
Dockerfile: reduce image size and update to latest scancode release
Browse files Browse the repository at this point in the history
- Updated base image to Python 3.12-slim
- Updated Scancode version to latest released version 32.3.0
- Do not get scancode archive using ADD as it bloats the image
  unecessarily
- Ensure apt-get is not too greedy and remove cache after install
- Install pip packages with --no-cache-dir option to save on image size

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
  • Loading branch information
kartben authored and stephanosio committed Oct 25, 2024
1 parent 3b91919 commit 99da313
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
FROM python:3.10

ENV SCANCODE_RELEASE=30.1.0

RUN apt-get update && apt-get install -y bzip2 xz-utils zlib1g libxml2-dev libxslt1-dev

ADD "https://github.com/nexB/scancode-toolkit/archive/refs/tags/v${SCANCODE_RELEASE}.tar.gz" .

RUN mkdir scancode-toolkit && tar xzvf v${SCANCODE_RELEASE}.tar.gz -C scancode-toolkit --strip-components=1

WORKDIR scancode-toolkit
FROM python:3.12-slim

ENV SCANCODE_RELEASE=32.3.0

RUN apt-get update && apt-get install --no-install-recommends -y \
build-essential \
git \
wget \
curl \
unzip \
bzip2 \
xz-utils \
zlib1g \
libxml2-dev \
libxslt1-dev \
libpopt0 \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir /opt/scancode-toolkit && \
wget -qO- "https://github.com/nexB/scancode-toolkit/archive/refs/tags/v${SCANCODE_RELEASE}.tar.gz" | \
tar xz --strip-components=1 -C /opt/scancode-toolkit

WORKDIR /opt/scancode-toolkit

RUN ./scancode --help

ENV PATH=$HOME/scancode-toolkit:$PATH
ENV PATH="/opt/scancode-toolkit:$PATH"

RUN pip3 install pyyaml
RUN pip3 install pyyaml --no-cache-dir

0 comments on commit 99da313

Please sign in to comment.