diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..38a1d04f96 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,60 @@ +# Git +.git +.gitignore +.github + +# Python +__pycache__ +*.py[cod] +*$py.class +*.so +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +venv/ +env/ +ENV/ + +# Testing +.pytest_cache/ +.coverage +htmlcov/ +tests/ +tests_*/ +test_external_plugins/ +conftest.py + +# IDE +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# Documentation +docs/ +*.md +!README.md + +# CI/CD +.pre-commit-config.yaml + +# Other +*.log +.DS_Store +scripts/ +snyk/ +performance_history_analysis.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..2f3f8708ef --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# step 1 - build the cli +FROM python:3.10-slim AS builder +WORKDIR /build +RUN apt-get update && apt-get install -y \ + gcc \ + g++ \ + libffi-dev \ + libssl-dev \ + git \ + && rm -rf /var/lib/apt/lists/* + +COPY pyproject.toml ./ +COPY README.md ./ +COPY LICENSE ./ +COPY src ./src + +RUN pip install --no-cache-dir hatch && hatch build -t wheel + +# step 2 - package the cli to a minimal image +FROM python:3.10-slim +RUN apt-get update && apt-get install -y libssl3 && rm -rf /var/lib/apt/lists/* +WORKDIR /app +COPY --from=builder /build/dist/*.whl /tmp/ +RUN pip install --no-cache-dir /tmp/*.whl && rm -rf /tmp/*.whl +ENV SF_SKIP_WARNING_FOR_READ_PERMISSIONS_ON_CONFIG_FILE=true +ENTRYPOINT ["snow"] +CMD ["--help"] diff --git a/build-docker.sh b/build-docker.sh new file mode 100755 index 0000000000..015d0f2559 --- /dev/null +++ b/build-docker.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" + +echo "Building snow-cli Docker image..." +echo "=======================================" + +docker build --progress=plain -t snow-cli "$SCRIPT_DIR" + +if [ $? -eq 0 ]; then + echo "" + echo "=======================================" + echo "Build successful!" + echo "Image: snow-cli:latest" + echo "" + echo "Usage:" + echo " docker run --rm snow-cli --version" + echo " docker run --rm snow-cli --help" +else + echo "" + echo "=======================================" + echo "Build failed!" + exit 1 +fi