Skip to content

Commit

Permalink
Optimize Dockerfiles for faster and smaller builds #350 (#354)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Druez <[email protected]>
  • Loading branch information
tdruez authored Oct 22, 2021
1 parent ff5f801 commit c55168a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
26 changes: 26 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
**/.git
**/.gitignore
**/.github
**/.vscode
**/.idea
**/coverage
**/.aws
**/.ssh
**/.DS_Store
**/venv
**/env
**/bin
**/docs
**/dist
**/etc
**/lib
**/var
**/*.egg-info
.dockerignore
.readthedocs.yaml
docker.env
CHANGELOG.rst
Dockerfile
README.rst
docker-compose.yml
pyvenv.cfg
16 changes: 10 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@

FROM python:3.9

WORKDIR /app

ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1

# Requirements as per https://scancode-toolkit.readthedocs.io/en/latest/getting-started/install.html
# OS requirements as per
# https://scancode-toolkit.readthedocs.io/en/latest/getting-started/install.html
RUN apt-get update \
&& apt-get install -y \
&& apt-get install -y --no-install-recommends \
bzip2 \
xz-utils \
zlib1g \
Expand All @@ -44,10 +47,11 @@ RUN apt-get update \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN mkdir /opt/scancodeio/ \
&& mkdir -p /var/scancodeio/static/ \
RUN mkdir -p /var/scancodeio/static/ \
&& mkdir -p /var/scancodeio/workspace/

COPY . /opt/scancodeio/
WORKDIR /opt/scancodeio/
# Keep the dependencies installation before the COPY of the app/ for proper caching
COPY setup.cfg setup.py /app/
RUN pip install .

COPY . /app
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ services:
expose:
- 8000
volumes:
- .:/opt/scancodeio/
- /etc/scancodeio/:/etc/scancodeio/
- workspace:/var/scancodeio/workspace/
- static:/var/scancodeio/static/
Expand All @@ -35,7 +34,6 @@ services:
env_file:
- docker.env
volumes:
- .:/opt/scancodeio/
- /etc/scancodeio/:/etc/scancodeio/
- workspace:/var/scancodeio/workspace/
depends_on:
Expand Down
3 changes: 2 additions & 1 deletion scancodeio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
SCAN_NOTICE = Path(__file__).resolve().parent.joinpath("scan.NOTICE").read_text()


# Turn off the warnings from the `parameter_expansion` module.
# Turn off the warnings from the `parameter_expansion` and `cluecode` modules.
warnings.filterwarnings("ignore", module="parameter_expansion")
warnings.filterwarnings("ignore", module="cluecode")


def command_line():
Expand Down

0 comments on commit c55168a

Please sign in to comment.