-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathDockerfile.preview
More file actions
68 lines (56 loc) · 1.91 KB
/
Copy pathDockerfile.preview
File metadata and controls
68 lines (56 loc) · 1.91 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
# syntax=docker/dockerfile:1
FROM socketdev/cli:latest
ARG SDK_PREVIEW_VERSION=""
ARG PYPI_INDEX_URL=https://pypi.org/simple/
ARG TEST_PYPI_INDEX_URL=https://test.pypi.org/simple/
COPY dist/socketsecurity-*.whl /tmp/socket-preview/
RUN <<'SH'
set -eux
wheel=$(find /tmp/socket-preview -maxdepth 1 -name 'socketsecurity-*.whl' -print -quit)
# Resolve every wheel dependency from production PyPI. When an exact SDK
# preview is requested, leave socketdev out so the prerelease can intentionally
# override a final-version floor such as socketdev>=3.4.0.
python - "$wheel" > /tmp/socket-preview/requirements.txt <<'PY'
import email
import os
import sys
import zipfile
from packaging.requirements import Requirement
from packaging.utils import canonicalize_name
wheel_path = sys.argv[1]
with zipfile.ZipFile(wheel_path) as archive:
metadata_path = next(
name for name in archive.namelist() if name.endswith(".dist-info/METADATA")
)
metadata = email.message_from_bytes(archive.read(metadata_path))
sdk_preview = os.environ.get("SDK_PREVIEW_VERSION")
for value in metadata.get_all("Requires-Dist", []):
if sdk_preview and canonicalize_name(Requirement(value).name) == "socketdev":
continue
print(value)
PY
python -m pip install \
--no-cache-dir \
--index-url "$PYPI_INDEX_URL" \
--requirement /tmp/socket-preview/requirements.txt
if [ -n "$SDK_PREVIEW_VERSION" ]; then
mkdir /tmp/socket-preview/sdk
python -m pip download \
--no-cache-dir \
--no-deps \
--dest /tmp/socket-preview/sdk \
--index-url "$TEST_PYPI_INDEX_URL" \
"socketdev==$SDK_PREVIEW_VERSION"
python -m pip install \
--no-cache-dir \
--index-url "$PYPI_INDEX_URL" \
/tmp/socket-preview/sdk/socketdev-*.whl
fi
python -m pip install \
--no-cache-dir \
--no-deps \
--force-reinstall \
"$wheel"
socketcli --help >/dev/null
rm -rf /tmp/socket-preview
SH