fix(#61): не оставлять pip в runtime-образе
ci / lint (push) Successful in 52s
ci / lint (pull_request) Successful in 44s
contract-openapi / openapi-contract (push) Successful in 50s
contract-openapi / ts-client-is-current (push) Successful in 52s
contract-openapi / openapi-contract (pull_request) Failing after 13m2s
ci / unit (push) Has been cancelled
ci / security (push) Has been cancelled
ci / unit (pull_request) Has been cancelled
ci / security (pull_request) Has been cancelled
contract-openapi / ts-client-is-current (pull_request) Has been cancelled
ci / build (push) Has been cancelled
ci / image-scan (push) Has been cancelled
ci / push (push) Has been cancelled
ci / build (pull_request) Has been cancelled
ci / image-scan (pull_request) Has been cancelled
ci / push (pull_request) Has been cancelled
ci / lint (push) Successful in 52s
ci / lint (pull_request) Successful in 44s
contract-openapi / openapi-contract (push) Successful in 50s
contract-openapi / ts-client-is-current (push) Successful in 52s
contract-openapi / openapi-contract (pull_request) Failing after 13m2s
ci / unit (push) Has been cancelled
ci / security (push) Has been cancelled
ci / unit (pull_request) Has been cancelled
ci / security (pull_request) Has been cancelled
contract-openapi / ts-client-is-current (pull_request) Has been cancelled
ci / build (push) Has been cancelled
ci / image-scan (push) Has been cancelled
ci / push (push) Has been cancelled
ci / build (pull_request) Has been cancelled
ci / image-scan (pull_request) Has been cancelled
ci / push (pull_request) Has been cancelled
trivy разбирает pip/_vendor/vendor.txt и репортит вендоренные msgpack 1.1.2 / urllib3 2.7.0 / setuptools 70.3.0 как установленные пакеты — при том что в venv реально стоят 1.2.4 / 2.8.0 / 84.2.1 (проверено pip list внутри образа staging-cc3621a1). py3-pip переведён в .build-deps и удаляется вместе с ними; pip в venv и системный pip вычищаются — runtime не должен содержать инсталлятора. Refs #61
This commit is contained in:
+10
-3
@@ -54,7 +54,7 @@ LABEL org.opencontainers.image.title="awg-dash" \
|
||||
# curl (HEALTHCHECK), tini (PID 1), su-exec (запуск API под непривилегированным пользователем).
|
||||
RUN apk add --no-cache \
|
||||
bash curl iproute2 ipset iptables ip6tables dnsmasq \
|
||||
python3 py3-pip tini su-exec \
|
||||
python3 tini su-exec \
|
||||
&& addgroup -S awg \
|
||||
&& adduser -S -G awg -h /app awg
|
||||
|
||||
@@ -70,11 +70,18 @@ ENV PATH=/opt/venv/bin:$PATH \
|
||||
|
||||
WORKDIR /app
|
||||
COPY requirements.txt /app/requirements.txt
|
||||
RUN apk add --no-cache --virtual .build-deps gcc musl-dev python3-dev libffi-dev \
|
||||
# py3-pip нужен только на время сборки venv: в runtime pip не остаётся. Иначе trivy разбирает
|
||||
# pip/_vendor/vendor.txt и репортит вендоренные версии (msgpack 1.1.2 / urllib3 2.7.0 /
|
||||
# setuptools 70.3.0) как установленные пакеты — ложные HIGH на образе, где стоят 1.2.4/2.8.0/84.2.1 (issue #61).
|
||||
RUN apk add --no-cache --virtual .build-deps gcc musl-dev python3-dev libffi-dev py3-pip \
|
||||
&& python3 -m venv /opt/venv \
|
||||
&& /opt/venv/bin/pip install --no-cache-dir --upgrade pip \
|
||||
&& /opt/venv/bin/pip install --no-cache-dir -r /app/requirements.txt \
|
||||
&& apk del .build-deps
|
||||
&& apk del .build-deps \
|
||||
&& rm -rf /opt/venv/lib/python3*/site-packages/pip /opt/venv/lib/python3*/site-packages/pip-* \
|
||||
&& rm -f /opt/venv/bin/pip /opt/venv/bin/pip3 /opt/venv/bin/pip3.* \
|
||||
&& rm -rf /usr/lib/python3*/site-packages/pip /usr/lib/python3*/site-packages/pip-* \
|
||||
&& rm -f /usr/bin/pip3 /usr/bin/pip3.*
|
||||
|
||||
COPY backend/ /app/backend/
|
||||
COPY --from=go-build /usr/local/bin/awg /usr/local/bin/awg
|
||||
|
||||
Reference in New Issue
Block a user