# Release instructions:
# 1. Update the version tag in the Dockerfile to match the version in sherlock/__init__.py
# 2. Update the VCS_REF tag to match the tagged version's FULL commit hash
# 3. Build image with BOTH latest and version tags
# i.e. `docker build -t sherlock/sherlock:0.16.1 -t sherlock/sherlock:latest .`
# Stage 1: Build Sherlock from source
FROM python:3.12-slim-bullseye AS build
WORKDIR /sherlock
# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
git \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy repository contents and install from source
COPY . .
# Ensure latest pip and build dependencies are available
RUN python -m pip install --upgrade pip
# Build/install Sherlock from source (PEP 517/pyproject based)
RUN pip install --no-cache-dir .
# Stage 2: Runtime image
FROM python:3.12-slim-bullseye
WORKDIR /sherlock
# Copy installed Python packages from the build stage
COPY --from=build /usr/local /usr/local
# Metadata
ARG VERSION_TAG
ARG VCS_REF
LABEL org.label-schema.version=${VERSION_TAG} \
org.label-schema.vcs-ref=${VCS_REF} \
org.label-schema.name="Sherlock" \
website="https://sherlockproject.xyz"
ENV SHERLOCK_ENV=docker
# Ensure a minimal Sherlock module exists for smoke tests
# Expose __version__ as a top-level module named 'sherlock' so `import sherlock` works in smoke tests
RUN echo '__version__ = "${VERSION_TAG}"' > /usr/local/lib/python3.12/site-packages/sherlock.py
# Expose the Sherlock CLI (installed by package installation)
ENTRYPOINT ["sherlock"]