Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
110 lines (96 loc) · 5.94 KB
/
Copy pathDockerfile
File metadata and controls
110 lines (96 loc) · 5.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# ─── Global version pins (single source of truth) ────────────────────────────
# Dependabot tracks all ARGs below via the FROM lines that reference them.
# To override at build time: docker build --build-arg TRUFFLEHOG_VERSION=3.93.8 .
#
# Dependabot-trackable (each has a corresponding FROM <image>:<ARG> stage):
ARG PYTHON_VERSION=3.12
ARG TRUFFLEHOG_VERSION=3.96.0
ARG UV_VERSION=0.12.1
#
# NOT Dependabot-trackable (no official Docker image with a stable binary path):
ARG OPENGREP_VERSION=v1.26.0
ARG SOCKET_NPM_CLI_VERSION=1.1.165
#
# NOT Dependabot-trackable — Socket-built Trivy, rebuilt from unmodified upstream
# source and published by Socket's own release pipeline. Pinned by digest; both
# ARGs are updated together by that release process, never bumped independently.
# Building requires pull access to the registry; contributors without it can
# override, e.g.: docker build --build-arg TRIVY_IMAGE=aquasec/trivy:0.76.1 .
# TRIVY_VERSION feeds the image label — keep it in sync with the TRIVY_IMAGE tag.
# -socket.N is a trivy-dist toolchain rebuild: same upstream source, newer Go.
ARG TRIVY_VERSION=0.76.1
ARG TRIVY_IMAGE=ghcr.io/socketdev/trivy:0.76.1@sha256:883da3593a60e311b2ed87c3a55241051b27bba15ffc3ce041ae570cd0f00915
# ─── Stage: trivy (Socket-built redistribution) ───────────────────────────────
FROM ${TRIVY_IMAGE} AS trivy
# ─── Stage: trufflehog (Dependabot-trackable) ─────────────────────────────────
FROM trufflesecurity/trufflehog:${TRUFFLEHOG_VERSION} AS trufflehog
# ─── Stage: uv (Dependabot-trackable) ─────────────────────────────────────────
# Named stage required — COPY --from does not support ARG variable expansion.
FROM ghcr.io/astral-sh/uv:${UV_VERSION} AS uv
# ─── Stage: opengrep-installer ────────────────────────────────────────────────
# OpenGrep does not publish an official Docker image with a stable binary path,
# so we install via their official script in a dedicated build stage.
# NOTE: OPENGREP_VERSION is not Dependabot-trackable; update manually above.
FROM python:${PYTHON_VERSION}-slim AS opengrep-installer
ARG OPENGREP_VERSION
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
curl ca-certificates bash
RUN curl -fsSL https://raw.githubusercontent.com/opengrep/opengrep/main/install.sh \
| bash -s -- -v "${OPENGREP_VERSION}"
# ─── Stage: runtime ───────────────────────────────────────────────────────────
FROM python:${PYTHON_VERSION}-slim AS runtime
WORKDIR /socket-basics
COPY --from=uv /uv /uvx /bin/
# Binary tools from immutable build stages
COPY --from=trivy /usr/local/bin/trivy /usr/local/bin/trivy
COPY --from=trufflehog /usr/bin/trufflehog /usr/local/bin/trufflehog
COPY --from=opengrep-installer /root/.opengrep /root/.opengrep
# System deps + Node.js 22.x + Socket CLI
# ca-certificates must be 20250419+deb13u1 or newer, which drops the roots the
# compromised eMudhra intermediates chain to.
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
curl git wget ca-certificates \
&& dpkg --compare-versions "$(dpkg-query -W -f='${Version}' ca-certificates)" ge 20250419+deb13u1
# pip checks certificates against its own vendored CA bundle, not the system
# store, and the base image's pip trusts the compromised intermediates. 26.2.2
# vendors certifi 2026.10.19. Upgrade it against the system store fixed above.
RUN python -m pip install --no-cache-dir --cert /etc/ssl/certs/ca-certificates.crt --upgrade "pip>=26.2.2" \
&& python -c 'import sys, pip; sys.exit(tuple(map(int, pip.__version__.split(".")[:3])) < (26, 2, 2))'
# Node rejects the compromised eMudhra intermediates from 22.23.4.
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs \
&& node -e 'const [a,b,c]=process.versions.node.split(".").map(Number); process.exit(a>22||(a===22&&(b>23||(b===23&&c>=4)))?0:1)'
ARG SOCKET_NPM_CLI_VERSION
RUN --mount=type=cache,target=/root/.npm \
npm install -g "socket@${SOCKET_NPM_CLI_VERSION}"
# Python project files
COPY socket_basics /socket-basics/socket_basics
COPY pyproject.toml README.md LICENSE uv.lock /socket-basics/
# Install Python deps (uv cache speeds up repeated local builds)
ENV UV_LINK_MODE=copy
RUN --mount=type=cache,target=/root/.cache/uv \
pip install -e . && uv sync --frozen --no-dev
# OCI image labels — baked-in tool versions + build provenance
# Values are populated by the publish-docker workflow; local builds use defaults.
ARG SOCKET_BASICS_VERSION=dev
ARG VCS_REF=unknown
ARG BUILD_DATE=unknown
ARG TRIVY_VERSION
ARG TRUFFLEHOG_VERSION
ARG OPENGREP_VERSION
ARG SOCKET_NPM_CLI_VERSION
LABEL org.opencontainers.image.title="Socket Basics" \
org.opencontainers.image.source="https://github.com/SocketDev/socket-basics" \
org.opencontainers.image.version="${SOCKET_BASICS_VERSION}" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.revision="${VCS_REF}" \
com.socket.trivy-version="${TRIVY_VERSION}" \
com.socket.trufflehog-version="${TRUFFLEHOG_VERSION}" \
com.socket.opengrep-version="${OPENGREP_VERSION}" \
com.socket.npm-cli-version="${SOCKET_NPM_CLI_VERSION}"
ENV PATH="/socket-basics/.venv/bin:/root/.opengrep/cli/latest:/usr/local/bin:$PATH"
ENTRYPOINT ["socket-basics"]