Skip to content

Instantly share code, notes, and snippets.

@jonnyzzz
Created March 4, 2026 12:20
Show Gist options
  • Select an option

  • Save jonnyzzz/711beb37b0a42f4f54de16a6f2974e33 to your computer and use it in GitHub Desktop.

Select an option

Save jonnyzzz/711beb37b0a42f4f54de16a6f2974e33 to your computer and use it in GitHub Desktop.
marninator build.sh auto-download repo zip patch for JetBrains/marinator issue #1
From effc7a249e6f3deedc1d566f671159ceeb4d8376 Mon Sep 17 00:00:00 2001
From: Eugene Petrenko <eugene.petrenko@jetbrains.com>
Date: Wed, 4 Mar 2026 13:19:41 +0100
Subject: [PATCH] build: auto-download IntelliJ repo zip when missing
---
README.md | 23 +++++++++++-------
build.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++----------
2 files changed, 74 insertions(+), 20 deletions(-)
diff --git a/README.md b/README.md
index 058fa5c..b903ada 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,8 @@ Docker container for AI agents working on IntelliJ IDEA monorepo. Includes Intel
- Docker with BuildKit
- SSH key configured for GitHub (`ssh -T git@github.com` must succeed) — needed to clone marinade, run-agent, and jb-cli during build
- ~10GB disk space
-- IntelliJ monorepo git clone zip — go to [Space repo](https://jetbrains.team/p/ij/repositories/ultimate/files/master/README.md), click **Start config**, then download the **Linux** zip
+- IntelliJ monorepo git clone zip (optional if auto-download is used) — go to [Space repo](https://jetbrains.team/p/ij/repositories/ultimate/files/master/README.md), click **Start config**, then download the **Linux** zip
+- VPN access if using auto-download from TeamCity (`buildserver.labs.intellij.net`)
## Quick Start
@@ -15,6 +16,9 @@ Docker container for AI agents working on IntelliJ IDEA monorepo. Includes Intel
# 1. Get credentials.env from 1Password (ask @mfilippov for access)
# 2. Build
+./build.sh
+
+# Optional: use an explicit zip path instead of auto-download
./build.sh ~/Downloads/ultimate-git-clone-linux.zip
# 3. Run
@@ -83,13 +87,16 @@ INTELLIJ_LICENSE_OFFLINE_CODE= # IntelliJ license (build-time only)
## Build Details
`build.sh` does the following:
-1. Fetches latest IntelliJ IDEA release from JetBrains API
-2. Clones marinade and builds jb-cli from GitHub
-3. Extracts monorepo from zip, checks out `master`
-4. Installs JBR (version from repo's `dependencies.properties`)
-5. Downloads plugins, installs MCP Steroid
-6. Runs IJPrivatePackagesAuthorizer for Space Maven packages
-7. Runs IntelliJ warmup (indexing + build)
+1. Uses provided monorepo zip, or auto-downloads it from TeamCity (`REPO_ZIP_URL`) into `REPO_ZIP_PATH` (default `~/Downloads/ultimate-git-clone-linux.zip`)
+2. Fetches latest IntelliJ IDEA release from JetBrains API
+3. Clones marinade and builds jb-cli from GitHub
+4. Extracts monorepo from zip, checks out `master`
+5. Installs JBR (version from repo's `dependencies.properties`)
+6. Downloads plugins, installs MCP Steroid
+7. Runs IJPrivatePackagesAuthorizer for Space Maven packages
+8. Runs IntelliJ warmup (indexing + build)
+
+Auto-download uses `curl --continue-at -` and writes to `*.part`, renaming to the final zip path only after successful completion.
Secrets (`SPACE_TOKEN`, `INTELLIJ_LICENSE_OFFLINE_CODE`) are passed via BuildKit `--mount=type=secret` and not baked into image layers.
diff --git a/build.sh b/build.sh
index 060c93a..ccb096b 100755
--- a/build.sh
+++ b/build.sh
@@ -3,18 +3,69 @@ set -euo pipefail
# =============================================================================
# Marinator Docker Image Build Script
-# Usage: ./build.sh <repo.zip>
+# Usage: ./build.sh [repo.zip]
# =============================================================================
-REPO_ZIP="${1:-}"
-if [ -z "$REPO_ZIP" ]; then
- echo "Usage: ./build.sh <repo.zip>"
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+IMAGE_NAME="${IMAGE_NAME:-local/marinator}"
+IMAGE_TAG="${IMAGE_TAG:-latest}"
+REPO_ZIP_URL="${REPO_ZIP_URL:-https://buildserver.labs.intellij.net/repository/download/ijplatform_master_Service_PrepareGitClonePerOS_Linux/.lastSuccessful/ultimate-git-clone-linux.zip}"
+DEFAULT_REPO_ZIP_PATH="${REPO_ZIP_PATH:-$HOME/Downloads/ultimate-git-clone-linux.zip}"
+
+print_usage() {
+ echo "Usage: ./build.sh [repo.zip]"
echo ""
- echo " repo.zip Path to IntelliJ monorepo git clone zip"
+ echo " repo.zip Optional path to IntelliJ monorepo git clone zip"
echo ""
- echo "Example:"
- echo " ./build.sh ~/Downloads/ultimate-git-clone-linux.zip"
- exit 1
+ echo "If omitted, the script downloads it from TeamCity to:"
+ echo " $DEFAULT_REPO_ZIP_PATH"
+ echo ""
+ echo "Environment overrides:"
+ echo " REPO_ZIP_URL Download URL for repo zip"
+ echo " REPO_ZIP_PATH Destination path for downloaded zip"
+}
+
+download_repo_zip() {
+ local dest_path="${1:?destination path is required}"
+ local tmp_path="${dest_path}.part"
+
+ mkdir -p "$(dirname "$dest_path")"
+
+ echo "Download URL: $REPO_ZIP_URL"
+ echo "Download destination: $dest_path"
+
+ if [ -f "$dest_path" ]; then
+ echo "Using existing repository archive: $dest_path"
+ return
+ fi
+
+ if [ -f "$tmp_path" ]; then
+ echo "Resuming download from partial file: $tmp_path"
+ else
+ echo "Starting repository download..."
+ fi
+
+ if ! curl -fL --continue-at - --output "$tmp_path" "$REPO_ZIP_URL"; then
+ echo "Error: failed to download repository archive."
+ echo "Partial file preserved at: $tmp_path"
+ exit 1
+ fi
+
+ mv -f "$tmp_path" "$dest_path"
+ echo "Repository archive downloaded: $dest_path"
+}
+
+if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
+ print_usage
+ exit 0
+fi
+
+REPO_ZIP="${1:-}"
+if [ -z "$REPO_ZIP" ]; then
+ REPO_ZIP="$DEFAULT_REPO_ZIP_PATH"
+ echo "No repository archive path provided."
+ echo "We are going to download the IntelliJ Ultimate repository, make sure the VPN is enabled"
+ download_repo_zip "$REPO_ZIP"
fi
if [ ! -f "$REPO_ZIP" ]; then
@@ -23,10 +74,6 @@ if [ ! -f "$REPO_ZIP" ]; then
fi
REPO_ZIP="$(cd "$(dirname "$REPO_ZIP")" && pwd)/$(basename "$REPO_ZIP")"
-SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
-IMAGE_NAME="${IMAGE_NAME:-local/marinator}"
-IMAGE_TAG="${IMAGE_TAG:-latest}"
-
# Load credentials (safe KEY=VALUE parser, no arbitrary code execution)
if [ -f "$SCRIPT_DIR/credentials.env" ]; then
eval "$(bash "$SCRIPT_DIR/scripts/load-env.sh" "$SCRIPT_DIR/credentials.env")"
--
2.51.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment