Skip to content

Commit 2684a9d

Browse files
authored
Doug/fix uv default path (#128)
* Fixed docker build to have uv in the default path * Fix default path for UV and minimum SDK version to fix tar hash upload * Ensuring socketdev is updated in the dockerfile
1 parent 144c4e2 commit 2684a9d

File tree

5 files changed

+81
-21
lines changed

5 files changed

+81
-21
lines changed

Dockerfile

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,38 @@ ARG CLI_VERSION
44
ARG SDK_VERSION
55
ARG PIP_INDEX_URL=https://pypi.org/simple
66
ARG PIP_EXTRA_INDEX_URL=https://pypi.org/simple
7+
ARG USE_LOCAL_INSTALL=false
78

89
RUN apk update \
910
&& apk add --no-cache git nodejs npm yarn curl \
1011
&& npm install @coana-tech/cli -g
1112

1213
# Install uv
13-
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
14-
ENV PATH="/root/.cargo/bin:${PATH}"
14+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
1515

16-
# Install CLI with retries for TestPyPI propagation (10 attempts, 30s each = 5 minutes total)
17-
RUN for i in $(seq 1 10); do \
18-
echo "Attempt $i/10: Installing socketsecurity==$CLI_VERSION"; \
19-
if pip install --index-url ${PIP_INDEX_URL} --extra-index-url ${PIP_EXTRA_INDEX_URL} socketsecurity==$CLI_VERSION; then \
20-
break; \
16+
# Install CLI based on build mode
17+
RUN if [ "$USE_LOCAL_INSTALL" = "true" ]; then \
18+
echo "Using local development install"; \
19+
else \
20+
for i in $(seq 1 10); do \
21+
echo "Attempt $i/10: Installing socketsecurity==$CLI_VERSION"; \
22+
if pip install --index-url ${PIP_INDEX_URL} --extra-index-url ${PIP_EXTRA_INDEX_URL} socketsecurity==$CLI_VERSION; then \
23+
break; \
24+
fi; \
25+
echo "Install failed, waiting 30s before retry..."; \
26+
sleep 30; \
27+
done && \
28+
if [ ! -z "$SDK_VERSION" ]; then \
29+
pip install --index-url ${PIP_INDEX_URL} --extra-index-url ${PIP_EXTRA_INDEX_URL} socketdev==${SDK_VERSION}; \
2130
fi; \
22-
echo "Install failed, waiting 30s before retry..."; \
23-
sleep 30; \
24-
done && \
25-
if [ ! -z "$SDK_VERSION" ]; then \
26-
pip install --index-url ${PIP_INDEX_URL} --extra-index-url ${PIP_EXTRA_INDEX_URL} socketdev==${SDK_VERSION}; \
27-
fi
31+
fi
32+
33+
# Copy local source and install in editable mode if USE_LOCAL_INSTALL is true
34+
COPY . /app
35+
WORKDIR /app
36+
RUN if [ "$USE_LOCAL_INSTALL" = "true" ]; then \
37+
pip install --upgrade -e .; \
38+
pip install --upgrade socketdev; \
39+
fi
40+
41+
# ENTRYPOINT ["socketcli"]

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
66

77
[project]
88
name = "socketsecurity"
9-
version = "2.2.23"
9+
version = "2.2.26"
1010
requires-python = ">= 3.10"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [
@@ -16,7 +16,7 @@ dependencies = [
1616
'GitPython',
1717
'packaging',
1818
'python-dotenv',
19-
'socketdev>=3.0.16,<4.0.0',
19+
'socketdev>=3.0.17,<4.0.0',
2020
"bs4>=0.0.2",
2121
]
2222
readme = "README.md"

scripts/build_container.sh

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ verify_package() {
2424

2525
echo $VERSION
2626
if [ -z $ENABLE_PYPI_BUILD ] || [ -z $STABLE_VERSION ]; then
27-
echo "$0 pypi-build=enable stable=true"
28-
echo "\tpypi-build: Build and publish a new version of the package to pypi. Options are prod or test"
29-
echo "\tstable: Only build and publish a new version for the stable docker tag if it has been tested and going on the changelog"
27+
echo "$0 pypi-build=<option> stable=<true|false|prod|test>"
28+
echo "\tpypi-build: Options are prod, test, or local"
29+
echo "\t - prod: Build and publish to production PyPI, then build Docker images"
30+
echo "\t - test: Build and publish to test PyPI, then build Docker images"
31+
echo "\t - local: Build Docker images only using existing PyPI package (specify prod or test via stable parameter)"
32+
echo "\tstable: true/false/prod/test - Also tag as stable; for local builds:"
33+
echo "\t - stable=prod: Use production PyPI package"
34+
echo "\t - stable=test: Use test PyPI package"
35+
echo "\t - stable=false: Use local development install (pip install -e .)"
3036
exit
3137
fi
3238

@@ -97,3 +103,44 @@ if [ $STABLE_VERSION = "stable=true" ]; then
97103
&& docker push socketdev/cli:stable
98104
fi
99105

106+
if [ $ENABLE_PYPI_BUILD = "pypi-build=local" ]; then
107+
echo "Building local version without publishing to PyPI"
108+
109+
# Determine PyPI source based on stable parameter
110+
if [ $STABLE_VERSION = "stable=prod" ]; then
111+
echo "Using production PyPI"
112+
PIP_INDEX_URL="https://pypi.org/simple"
113+
PIP_EXTRA_INDEX_URL="https://pypi.org/simple"
114+
TAG_SUFFIX="local"
115+
USE_LOCAL_INSTALL="false"
116+
elif [ $STABLE_VERSION = "stable=test" ]; then
117+
echo "Using test PyPI"
118+
PIP_INDEX_URL="https://test.pypi.org/simple"
119+
PIP_EXTRA_INDEX_URL="https://pypi.org/simple"
120+
TAG_SUFFIX="local-test"
121+
USE_LOCAL_INSTALL="false"
122+
elif [ $STABLE_VERSION = "stable=false" ]; then
123+
echo "Using local development install (pip install -e .)"
124+
TAG_SUFFIX="local-dev"
125+
USE_LOCAL_INSTALL="true"
126+
else
127+
echo "For local builds, use stable=prod, stable=test, or stable=false"
128+
exit 1
129+
fi
130+
131+
if [ $USE_LOCAL_INSTALL = "true" ]; then
132+
docker build --no-cache \
133+
--build-arg USE_LOCAL_INSTALL=true \
134+
-t socketdev/cli:$VERSION-$TAG_SUFFIX \
135+
-t socketdev/cli:$TAG_SUFFIX .
136+
else
137+
docker build --no-cache \
138+
--build-arg CLI_VERSION=$VERSION \
139+
--build-arg PIP_INDEX_URL=$PIP_INDEX_URL \
140+
--build-arg PIP_EXTRA_INDEX_URL=$PIP_EXTRA_INDEX_URL \
141+
-t socketdev/cli:$VERSION-$TAG_SUFFIX \
142+
-t socketdev/cli:$TAG_SUFFIX .
143+
fi
144+
echo "Local build complete. Tagged as socketdev/cli:$VERSION-$TAG_SUFFIX and socketdev/cli:$TAG_SUFFIX"
145+
fi
146+

socketsecurity/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__author__ = 'socket.dev'
2-
__version__ = '2.2.23'
2+
__version__ = '2.2.26'
33
USER_AGENT = f'SocketPythonCLI/{__version__}'

socketsecurity/socketcli.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,7 @@ def main_code():
251251
org_slug=org_slug,
252252
file_paths=manifest_files,
253253
workspace=config.repo or "default-workspace",
254-
base_path=None,
255-
base_paths=base_paths,
254+
base_paths=[config.target_path],
256255
use_lazy_loading=False
257256
)
258257
log.info(f"Manifest upload successful, tar hash: {tar_hash}")

0 commit comments

Comments
 (0)