Skip to content

Commit f0905cf

Browse files
authored
feat: add "base" Docker build stage (#2142)
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent 0585f53 commit f0905cf

4 files changed

Lines changed: 36 additions & 11 deletions

File tree

Dockerfile

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ RUN --mount=type=cache,target=/root/.cache/uv \
5353
uv sync --frozen
5454

5555
# ============================================
56-
# Stage 2: Production stage
56+
# Stage 2: Production stage (base)
5757
# ============================================
5858

59-
FROM python:3.13-slim-bookworm
59+
FROM python:3.13-slim-bookworm AS base
6060

6161
LABEL org.opencontainers.image.source="https://github.com/aboutcode-org/scancode.io"
6262
LABEL org.opencontainers.image.description="ScanCode.io"
@@ -94,8 +94,6 @@ RUN apt-get update \
9494
libzstd1 \
9595
libgpgme11 \
9696
libdevmapper1.02.1 \
97-
libguestfs-tools \
98-
linux-image-amd64 \
9997
git \
10098
wait-for-it \
10199
universal-ctags \
@@ -122,3 +120,18 @@ USER $APP_USER
122120

123121
# Create static/ and workspace/ directories
124122
RUN mkdir -p /var/$APP_NAME/static/ /var/$APP_NAME/workspace/
123+
124+
# ============================================
125+
# Stage 3: Full image (with VM inspection)
126+
# ============================================
127+
128+
FROM base AS full
129+
130+
USER root
131+
RUN apt-get update \
132+
&& apt-get install -y --no-install-recommends \
133+
libguestfs-tools \
134+
linux-image-amd64 \
135+
&& apt-get clean \
136+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
137+
USER $APP_USER

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ docs:
150150
@${ACTIVATE} sphinx-build docs/ docs/_build/
151151

152152
build:
153-
docker build -t $(IMAGE_NAME) .
153+
docker build --target base -t $(IMAGE_NAME) .
154+
155+
build-full:
156+
docker build --target full -t $(IMAGE_NAME) .
154157

155158
bash:
156159
docker run -it $(IMAGE_NAME) bash

docker-compose.dev.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,27 @@
77
# $ SCANCODEIO_TEST_FIXTURES_REGEN=1 ./manage.py test
88

99
name: scancodeio
10+
11+
x-dev-env: &dev-env
12+
SCANCODEIO_DEBUG: "True"
13+
GUNICORN_RELOAD_FLAG: "--reload"
14+
15+
x-dev-build: &dev-build
16+
context: .
17+
target: base
18+
1019
services:
1120
web:
12-
env_file:
13-
- docker.dev.env
21+
build: *dev-build
22+
environment:
23+
<<: *dev-env
1424
volumes:
1525
- ./scanpipe:/opt/scancodeio/scanpipe
1626

1727
worker:
18-
env_file:
19-
- docker.dev.env
28+
build: *dev-build
29+
environment:
30+
<<: *dev-env
2031
develop:
2132
watch:
2233
- action: sync+restart

docker.dev.env

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)