|
| 1 | +FROM python:3.12 |
| 2 | + |
| 3 | +# Install Node.js 20, OpenJDK and other system dependencies |
| 4 | + |
| 5 | +RUN apt-get update && apt-get install -y \ |
| 6 | + curl \ |
| 7 | + git \ |
| 8 | + build-essential \ |
| 9 | + nfs-common \ |
| 10 | + default-jdk \ |
| 11 | + apt-transport-https \ |
| 12 | + ca-certificates \ |
| 13 | + gnupg \ |
| 14 | + lsb-release \ |
| 15 | + iputils-ping \ |
| 16 | + net-tools \ |
| 17 | + vim \ |
| 18 | + wget \ |
| 19 | + && rm -rf /var/lib/apt/lists/* |
| 20 | + |
| 21 | +# Install Node.js 20.x |
| 22 | +RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ |
| 23 | + apt-get install -y nodejs |
| 24 | + |
| 25 | +# Upgrade system pip (separate for clearer error logs) |
| 26 | +RUN python -m pip install --upgrade pip |
| 27 | + |
| 28 | +# Update npm globally |
| 29 | +RUN npm install -g npm@latest |
| 30 | + |
| 31 | +# Enable corepack if present (Node 20 ships it); ignore if missing |
| 32 | +RUN (command -v corepack >/dev/null 2>&1 && corepack enable || echo "corepack not available, continuing") |
| 33 | + |
| 34 | +# Install yarn (try npm classic install first, fallback to corepack prepare) |
| 35 | +RUN (npm install -g yarn@latest || (command -v corepack >/dev/null 2>&1 && corepack prepare yarn@stable --activate) || echo "Yarn installation fallback used") |
| 36 | + |
| 37 | +# Set working directory |
| 38 | +WORKDIR /cloudharness |
| 39 | + |
| 40 | +# Copy all requirements files first for better Docker layer caching |
| 41 | +COPY libraries/models/requirements.txt ./libraries/models/ |
| 42 | +COPY libraries/cloudharness-utils/requirements.txt ./libraries/cloudharness-utils/ |
| 43 | +COPY libraries/cloudharness-common/requirements.txt ./libraries/cloudharness-common/ |
| 44 | +COPY libraries/client/cloudharness_cli/requirements.txt ./libraries/client/cloudharness_cli/ |
| 45 | +COPY tools/deployment-cli-tools/requirements.txt ./tools/deployment-cli-tools/ |
| 46 | + |
| 47 | +# Install all external dependencies with caching |
| 48 | +RUN --mount=type=cache,target=/root/.cache \ |
| 49 | + pip install -r libraries/models/requirements.txt --prefer-binary && \ |
| 50 | + pip install -r libraries/cloudharness-utils/requirements.txt --prefer-binary && \ |
| 51 | + pip install -r libraries/cloudharness-common/requirements.txt --prefer-binary && \ |
| 52 | + pip install -r libraries/client/cloudharness_cli/requirements.txt --prefer-binary && \ |
| 53 | + pip install -r tools/deployment-cli-tools/requirements.txt --prefer-binary |
| 54 | + |
| 55 | +# Copy requirements files for common framework libraries |
| 56 | +COPY infrastructure/common-images/cloudharness-fastapi/libraries/fastapi/requirements.txt ./infrastructure/fastapi-requirements.txt |
| 57 | +COPY infrastructure/common-images/cloudharness-flask/requirements.txt ./infrastructure/flask-requirements.txt |
| 58 | + |
| 59 | +# Install additional tools and common framework libraries |
| 60 | +RUN --mount=type=cache,target=/root/.cache \ |
| 61 | + pip install pytest debugpy --prefer-binary && \ |
| 62 | + pip install -r infrastructure/fastapi-requirements.txt --prefer-binary && \ |
| 63 | + pip install -r infrastructure/flask-requirements.txt --prefer-binary |
| 64 | + |
| 65 | +# Copy and install libraries one by one |
| 66 | +COPY libraries/models ./libraries/models |
| 67 | +RUN pip install -e libraries/models --no-cache-dir |
| 68 | + |
| 69 | +COPY libraries/cloudharness-utils ./libraries/cloudharness-utils |
| 70 | +RUN pip install -e libraries/cloudharness-utils --no-cache-dir |
| 71 | + |
| 72 | +COPY libraries/cloudharness-common ./libraries/cloudharness-common |
| 73 | +RUN pip install -e libraries/cloudharness-common --no-cache-dir |
| 74 | + |
| 75 | +COPY libraries/client/cloudharness_cli ./libraries/client/cloudharness_cli |
| 76 | +RUN pip install -e libraries/client/cloudharness_cli --no-cache-dir |
| 77 | + |
| 78 | +COPY tools/deployment-cli-tools ./tools/deployment-cli-tools |
| 79 | +RUN pip install -e tools/deployment-cli-tools --no-cache-dir |
| 80 | + |
| 81 | + |
| 82 | +# Copy and install cloudharness framework libraries (last to ensure they override any conflicts) |
| 83 | +COPY infrastructure/common-images/cloudharness-django/libraries/cloudharness-django infrastructure/cloudharness-django |
| 84 | +RUN pip install -e infrastructure/cloudharness-django --no-cache-dir || echo "cloudharness-django not installable" |
| 85 | + |
| 86 | +# Ensure latest npm & yarn still available after project copy (optional refresh) |
| 87 | +RUN npm install -g npm@latest yarn@latest || true |
| 88 | + |
| 89 | +# Copy dev scripts for runtime virtual environment |
| 90 | +COPY dev-scripts ./dev-scripts |
| 91 | +RUN chmod +x ./dev-scripts/runtime-venv.sh ./dev-scripts/use-venv ./dev-scripts/vscode-setup.sh |
| 92 | + |
| 93 | +# Add the cloudharness CLI tools to PATH |
| 94 | +ENV PATH="/cloudharness/tools/deployment-cli-tools:${PATH}" |
| 95 | + |
| 96 | +# Set the default working directory |
| 97 | +WORKDIR /workspace |
| 98 | + |
| 99 | +# Default command |
| 100 | +CMD ["/bin/bash"] |
0 commit comments