Skip to content

Commit e2da56d

Browse files
authored
feat: Multi-platform package distribution with cross-architecture binary support (#21)
* feat: add multi-platform build support with Docker and improved distribution - Add Linux x64/ARM64 builds via Docker containers - Add Windows build system using AWS CodeBuild - Create distribute command for secure package sharing via S3 presigned URLs - Create builds command for monitoring CodeBuild status - Improve package command with platform-specific builds - Add Intel Mac build attempts (challenging due to architecture differences) - Update documentation for all new platform support - Fix monitoring token authentication bypass for OTEL telemetry This commit represents a working state with Nuitka before switching to PyInstaller for better cross-architecture support on macOS. * fix: resolve package distribution and Linux compatibility issues - Always create Claude Code settings.json for Bedrock configuration (not just monitoring) - Fix Windows paths in settings.json using forward slashes for compatibility - Fix package command to continue when Windows builds run in CodeBuild - Fix nested directory issue in Windows PowerShell extraction instructions - Fix Linux GLIBC compatibility by using Ubuntu 20.04 base (GLIBC 2.31) - Fix six.moves import errors with six==1.16.0 and proper hidden imports - Add Docker-based Linux testing infrastructure - Improve distribution command with progress tracking and better error handling - Update documentation for clarity and accuracy * chore: remove Nuitka migration documentation These intermediary development documents are not needed in the final solution. The project uses PyInstaller for all cross-platform binary builds.
1 parent b0ffca2 commit e2da56d

File tree

19 files changed

+4398
-488
lines changed

19 files changed

+4398
-488
lines changed

README.md

Lines changed: 80 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This guidance enables organizations to provide secure, centralized access to Cla
1212
- **Comprehensive Audit Trail**: Full CloudTrail logging of all Bedrock access
1313
- **Usage Monitoring**: Optional CloudWatch dashboards for tracking usage and costs
1414
- **Multi-Region Support**: Configure which AWS regions users can access Bedrock in
15+
- **Multi-Platform Support**: Windows, macOS (ARM & Intel), and Linux distributions
1516

1617
### For End Users
1718

@@ -20,6 +21,7 @@ This guidance enables organizations to provide secure, centralized access to Cla
2021
- **AWS CLI/SDK Integration**: Works with any AWS tool or SDK
2122
- **Secure Credential Storage**: Choice of OS keyring or session-based storage
2223
- **Multi-Profile Support**: Manage multiple authentication profiles
24+
- **Cross-Platform**: Works on Windows, macOS, and Linux
2325

2426
## Table of Contents
2527

@@ -58,18 +60,31 @@ poetry run ccwb init
5860
# Deploy infrastructure
5961
poetry run ccwb deploy
6062

61-
# Create distribution package for users
62-
poetry run ccwb package
63+
# Create distribution package for users (all platforms)
64+
poetry run ccwb package --target-platform=all
65+
66+
# Create and distribute package via secure URL (Optional)
67+
poetry run ccwb distribute
6368
```
6469

6570
2. Test package locally to verify end-user installation and access to Amazon Bedrock.
6671

67-
```
72+
```bash
6873
# Test package locally
6974
poetry run ccwb test
7075
```
7176

72-
3. [Distribute](#end-user-experience) package to end-users.
77+
3. Distribute package to end-users (optional).
78+
79+
```bash
80+
# Generate secure distribution URL (expires in 48 hours)
81+
poetry run ccwb distribute
82+
83+
# Or specify custom expiration
84+
poetry run ccwb distribute --expires-hours=72
85+
```
86+
87+
4. Share the generated URL with developers - no AWS credentials required for download.
7388

7489
### Cleanup
7590

@@ -117,7 +132,7 @@ _You are responsible for the cost of the AWS services used while running this gu
117132

118133
### Sample Cost Table
119134

120-
The following table provides a sample cost breakdown for deploying this guidance with 5,000 monthly active users in the US East (N. Virginia) Region for one month (monitoring is separate).
135+
The following table provides a sample cost breakdown for deploying this guidance with 5,000 monthly active users in the US East (N. Virginia) Region for one month (monitoring, analytics, and Windows builds would be separate).
121136

122137
| AWS service | Dimensions | Cost [USD] |
123138
| ---------------------- | -------------------------- | ---------- |
@@ -142,7 +157,9 @@ Based on AWS Pricing Calculator: [View Detailed Estimate](https://calculator.aws
142157
- CloudFormation stacks
143158
- Cognito Identity Pools
144159
- IAM roles and policies
145-
- (Optional) ECS tasks and CloudWatch dashboards
160+
- (Optional) Amazon Elastic Container Service (Amazon ECS) tasks and Amazon CloudWatch dashboards
161+
- (Optional) Amazon Athena, AWS Glue, AWS Lambda, and Amazon Data Firehose resources
162+
- (Optional) AWS CodeBuild
146163
- Amazon Bedrock activated in target regions
147164

148165
**OIDC Provider Requirements:**
@@ -167,7 +184,9 @@ The guidance can be deployed in any AWS region that supports:
167184

168185
- Amazon Cognito Identity Pools
169186
- Amazon Bedrock
170-
- (Optional) Amazon ECS Fargate for monitoring
187+
- (Optional) Amazon Elastic Container Service (Amazon ECS) tasks and Amazon CloudWatch dashboards
188+
- (Optional) Amazon Athena, AWS Glue, AWS Lambda, and Amazon Data Firehose resources
189+
- (Optional) AWS CodeBuild
171190

172191
### Cross-Region Inference
173192

@@ -179,6 +198,35 @@ Claude Code uses Amazon Bedrock's cross-region inference for optimal performance
179198

180199
This automatically routes requests across multiple AWS regions to ensure the best response times and highest availability. Modern Claude models (3.7+) require cross-region inference for access.
181200

201+
### Platform Support
202+
203+
The authentication tools support all major platforms:
204+
205+
| Platform | Architecture | Build Method | Installation |
206+
| -------- | --------------------- | --------------------------- | ------------ |
207+
| Windows | x64 | AWS CodeBuild (Nuitka) | install.bat |
208+
| macOS | ARM64 (Apple Silicon) | Native (PyInstaller) | install.sh |
209+
| macOS | Intel (x86_64) | Cross-compile (PyInstaller) | install.sh |
210+
| macOS | Universal (both) | Universal2 (PyInstaller) | install.sh |
211+
| Linux | x86_64 | Docker (PyInstaller) | install.sh |
212+
| Linux | ARM64 | Docker (PyInstaller) | install.sh |
213+
214+
**Build Requirements:**
215+
216+
- **Windows**: AWS CodeBuild with Nuitka (automated)
217+
- **macOS**: PyInstaller with architecture-specific builds
218+
- ARM64: Native build on Apple Silicon Macs
219+
- Intel: Optional - requires x86_64 Python environment on ARM Macs
220+
- Universal: Requires both architectures' Python libraries
221+
- **Linux**: Docker with PyInstaller (for building on non-Linux hosts)
222+
223+
### Optional: Intel Mac Builds
224+
225+
Intel Mac builds require an x86_64 Python environment on Apple Silicon Macs.
226+
See [CLI Reference](assets/docs/CLI_REFERENCE.md#intel-mac-build-setup-optional) for setup instructions.
227+
228+
If not configured, the package command will skip Intel builds and continue with other platforms.
229+
182230
## Implementation
183231

184232
### Step 1: Initialize Configuration
@@ -233,19 +281,37 @@ This creates the following AWS resources:
233281
Build the package for end users:
234282

235283
```bash
236-
poetry run ccwb package
284+
# Build all platforms (starts Windows build in background)
285+
poetry run ccwb package --target-platform all
286+
287+
# Check Windows build status (optional)
288+
poetry run ccwb builds
289+
290+
# When ready, create distribution URL (optional)
291+
poetry run ccwb distribute
237292
```
238293

239-
This creates a `dist/` folder containing:
294+
**Package Workflow:**
295+
296+
1. **Local builds**: macOS/Linux executables are built locally using PyInstaller
297+
2. **Windows builds**: Trigger AWS CodeBuild for Windows executables (20+ minutes) - requires enabling CodeBuild during `init`
298+
3. **Check status**: Monitor build progress with `poetry run ccwb builds`
299+
4. **Create distribution**: Use `distribute` to upload and generate presigned URLs
300+
301+
> **Note**: Windows builds are optional and require CodeBuild to be enabled during the `init` process. If not enabled, the package command will skip Windows builds and continue with other platforms.
302+
303+
The `dist/` folder will contain:
240304

241-
- `credential-process-macos` - Authentication executable for macOS
242-
- `credential-process-linux` - Authentication executable for Linux
305+
- `credential-process-macos-arm64` - Authentication executable for macOS ARM64
306+
- `credential-process-macos-intel` - Authentication executable for macOS Intel (if built)
307+
- `credential-process-windows.exe` - Authentication executable for Windows
308+
- `credential-process-linux` - Authentication executable for Linux (if built on Linux)
243309
- `config.json` - Embedded configuration
244-
- `install.sh` - Installation script (auto-detects platform)
310+
- `install.sh` - Installation script for Unix systems
311+
- `install.bat` - Installation script for Windows
245312
- `README.md` - User instructions
246313
- `.claude/settings.json` - Claude Code telemetry settings (if monitoring enabled)
247-
- `otel-helper-macos` - OTEL helper executable for macOS (if monitoring enabled)
248-
- `otel-helper-linux` - OTEL helper executable for Linux (if monitoring enabled)
314+
- `otel-helper-*` - OTEL helper executables for each platform (if monitoring enabled)
249315

250316
The package builder:
251317

assets/docs/CLI_REFERENCE.md

Lines changed: 175 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ This document provides a complete reference for all `ccwb` (Claude Code with Bed
1313
- [`deploy` - Deploy Infrastructure](#deploy---deploy-infrastructure)
1414
- [`test` - Test Package](#test---test-package)
1515
- [`package` - Create Distribution](#package---create-distribution)
16+
- [`builds` - List and Manage CodeBuild Builds](#builds---list-and-manage-codebuild-builds)
17+
- [`distribute` - Create Distribution URLs](#distribute---create-distribution-urls)
1618
- [`status` - Check Deployment Status](#status---check-deployment-status)
1719
- [`cleanup` - Remove Installed Components](#cleanup---remove-installed-components)
1820
- [`destroy` - Remove Infrastructure](#destroy---remove-infrastructure)
@@ -63,6 +65,7 @@ poetry run ccwb init [options]
6365
- Configures cross-region inference profiles (US, Europe, APAC)
6466
- Prompts for source region selection for model inference
6567
- Sets up monitoring options
68+
- Prompts for Windows build support via AWS CodeBuild (optional)
6669
- Saves configuration to `.ccwb-config/config.json` in the project directory
6770

6871
**Note:** This command only creates configuration. Use `deploy` to create AWS resources.
@@ -99,6 +102,7 @@ poetry run ccwb deploy [stack] [options]
99102
3. **monitoring** - OpenTelemetry collector on ECS Fargate (optional)
100103
4. **dashboard** - CloudWatch dashboard for usage metrics (optional)
101104
5. **analytics** - Kinesis Firehose and Athena for analytics (optional)
105+
6. **codebuild** - AWS CodeBuild for Windows binary builds (optional, only if enabled during init)
102106

103107
### `test` - Test Package
104108

@@ -135,35 +139,195 @@ poetry run ccwb package [options]
135139

136140
**Options:**
137141

138-
- `--target-platform <platform>` - Target platform for binary: macos, linux, or all (default: "all")
142+
- `--target-platform <platform>` - Target platform for binary (default: "all")
143+
- `macos` - Build for current macOS architecture
144+
- `macos-arm64` - Build for Apple Silicon Macs
145+
- `macos-intel` - Build for Intel Macs (uses Rosetta on ARM Macs)
146+
- `linux` - Build for Linux (native, current architecture)
147+
- `linux-x64` - Build for Linux x64 using Docker
148+
- `linux-arm64` - Build for Linux ARM64 using Docker
149+
- `windows` - Build for Windows (uses CodeBuild - requires enabling during init)
150+
- `all` - Build for all available platforms
151+
- `--distribute` - Upload package and generate distribution URL
152+
- `--expires-hours <hours>` - Distribution URL expiration in hours (with --distribute) [default: "48"]
153+
- `--profile <name>` - Configuration profile to use [default: "default"]
139154

140155
**What it does:**
141156

142-
- Builds PyInstaller executable from authentication code
157+
- Builds Nuitka executable from authentication code
143158
- Creates configuration file with:
144159
- OIDC provider settings
145160
- Identity Pool ID from deployed stack
146161
- Credential storage method (keyring or session)
147162
- Selected Claude model and cross-region profile
148163
- Source region for model inference
149-
- Generates installer script
164+
- Generates installer script (install.sh for Unix, install.bat for Windows)
150165
- Creates user documentation
166+
- Optionally uploads to S3 and generates presigned URL (with --distribute)
167+
168+
**Platform Support (Hybrid Build System):**
169+
170+
- **macOS**: Uses PyInstaller with architecture-specific builds
171+
- ARM64: Native build on Apple Silicon Macs (works on all Macs)
172+
- Intel: **Optional** - requires x86_64 Python environment on ARM Macs
173+
- Universal: Requires both architectures' Python libraries (not currently automated)
174+
- **Linux**: Uses PyInstaller in Docker containers
175+
- x64: Uses linux/amd64 Docker platform
176+
- ARM64: Uses linux/arm64 Docker platform
177+
- Docker Desktop handles architecture emulation automatically
178+
- **Windows**: Uses Nuitka via AWS CodeBuild (if enabled during init)
179+
- Automated builds take 12-15 minutes
180+
- Requires CodeBuild to be enabled during `init`
181+
- Will be skipped if CodeBuild is not enabled
182+
183+
**Intel Mac Build Setup (Optional):**
184+
185+
To enable Intel builds on Apple Silicon Macs (optional):
186+
187+
```bash
188+
# Step 1: Install x86_64 Homebrew (if not already installed)
189+
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
190+
191+
# Step 2: Install x86_64 Python
192+
arch -x86_64 /usr/local/bin/brew install [email protected]
193+
194+
# Step 3: Create x86_64 virtual environment
195+
arch -x86_64 /usr/local/bin/python3.12 -m venv ~/venv-x86
196+
197+
# Step 4: Install required packages
198+
arch -x86_64 ~/venv-x86/bin/pip install pyinstaller boto3 keyring
199+
```
200+
201+
**Behavior when Intel environment is not set up:**
202+
203+
- For `--target-platform=all`: Skips Intel builds with a note, builds all other platforms
204+
- For `--target-platform=macos-intel`: Shows instructions for optional setup, skips the build
205+
- The package process continues successfully without Intel binaries
206+
- ARM64 binaries can be distributed to all Mac users (Intel and Apple Silicon)
207+
208+
**Graceful Fallback Behavior:**
209+
210+
The package command is designed to handle missing optional components gracefully:
211+
212+
- **Intel Mac builds**: Skipped if x86_64 Python environment is not available on ARM Macs
213+
- **Windows builds**: Skipped if CodeBuild was not enabled during `init`
214+
- **Linux builds**: Skipped if Docker is not available
215+
- **At least one platform must build successfully** for the package command to succeed
216+
217+
This ensures that packaging always works, even if some optional platforms are not available.
218+
219+
**Output files:**
220+
221+
- `credential-process-<platform>` - Authentication executable
222+
- `credential-process-macos-arm64` - macOS Apple Silicon
223+
- `credential-process-macos-intel` - macOS Intel
224+
- `credential-process-linux-x64` - Linux x64
225+
- `credential-process-linux-arm64` - Linux ARM64
226+
- `credential-process-windows.exe` - Windows x64
227+
- `otel-helper-<platform>` - OTEL helper (if monitoring enabled)
228+
- `config.json` - Configuration
229+
- `install.sh` - Unix installer script (auto-detects architecture)
230+
- `install.bat` - Windows installer script
231+
- `README.md` - Installation instructions
151232
- Includes Claude Code telemetry settings (if monitoring enabled)
152233
- Configures environment variables for model selection (ANTHROPIC_MODEL, ANTHROPIC_SMALL_FAST_MODEL)
153234

154235
**Output structure:**
155236

156237
```
157238
dist/
158-
├── credential-process-macos # macOS authentication executable
159-
├── credential-process-linux # Linux authentication executable
160-
├── otel-helper-macos # macOS OTEL helper (if monitoring enabled)
161-
├── otel-helper-linux # Linux OTEL helper (if monitoring enabled)
162-
├── config.json # Configuration
163-
├── install.sh # Installation script (auto-detects platform)
164-
├── README.md # User instructions
239+
├── credential-process-macos-arm64 # macOS ARM64 executable
240+
├── credential-process-macos-intel # macOS Intel executable
241+
├── credential-process-linux-x64 # Linux x64 executable
242+
├── credential-process-linux-arm64 # Linux ARM64 executable
243+
├── credential-process-windows.exe # Windows x64 executable
244+
├── otel-helper-macos-arm64 # macOS ARM64 OTEL helper
245+
├── otel-helper-macos-intel # macOS Intel OTEL helper
246+
├── otel-helper-linux-x64 # Linux x64 OTEL helper
247+
├── otel-helper-linux-arm64 # Linux ARM64 OTEL helper
248+
├── otel-helper-windows.exe # Windows OTEL helper
249+
├── config.json # Configuration
250+
├── install.sh # Unix installer (auto-detects architecture)
251+
├── install.bat # Windows installer
252+
├── README.md # User instructions
165253
└── .claude/
166-
└── settings.json # Telemetry settings (optional)
254+
└── settings.json # Telemetry settings (optional)
255+
```
256+
257+
### `builds` - List and Manage CodeBuild Builds
258+
259+
Shows recent Windows binary builds and their status.
260+
261+
```bash
262+
poetry run ccwb builds [options]
263+
```
264+
265+
**Options:**
266+
267+
- `--limit <n>` - Number of builds to show (default: "10")
268+
- `--project <name>` - CodeBuild project name (default: auto-detect)
269+
- `--status <id>` - Check status of a specific build by ID
270+
271+
**What it does:**
272+
273+
- Lists recent CodeBuild builds for Windows binaries
274+
- Shows build status, duration, and completion time
275+
- Provides console links to view full build logs
276+
- Monitors in-progress builds
277+
278+
**Note:** This command requires CodeBuild to be enabled during the `init` process. If CodeBuild was not enabled, you'll need to re-run `init` and enable Windows build support.
279+
280+
**Example output:**
281+
282+
```
283+
Recent Windows Builds
284+
285+
| Build ID | Status | Started | Duration |
286+
|----------|--------|---------|----------|
287+
| project:abc123 | SUCCEEDED | 2024-08-26 10:15 | 12m 34s |
288+
| project:def456 | IN_PROGRESS | 2024-08-26 10:30 | - |
289+
```
290+
291+
### `distribute` - Create Distribution URLs
292+
293+
Creates secure presigned URLs for package distribution.
294+
295+
```bash
296+
poetry run ccwb distribute [options]
297+
```
298+
299+
**Options:**
300+
301+
- `--expires-hours <hours>` - URL expiration time in hours (1-168) [default: "48"]
302+
- `--get-latest` - Retrieve the latest distribution URL
303+
- `--profile <name>` - Configuration profile to use [default: "default"]
304+
305+
**What it does:**
306+
307+
- Uploads built packages to S3
308+
- Generates presigned URLs for secure distribution
309+
- Stores URLs in Parameter Store for team access
310+
- No AWS credentials required for end users
311+
312+
**Distribution workflow:**
313+
314+
1. Build packages: `poetry run ccwb package --target-platform=all`
315+
2. Create distribution: `poetry run ccwb distribute`
316+
3. Share the generated URL with developers
317+
4. Developers download and run installer without AWS access
318+
319+
**Example:**
320+
321+
```bash
322+
# Build and distribute
323+
poetry run ccwb package --target-platform=all --distribute
324+
325+
# Or separately
326+
poetry run ccwb package --target-platform=all
327+
poetry run ccwb distribute --expires-hours=72
328+
329+
# Get existing URL
330+
poetry run ccwb distribute --get-latest
167331
```
168332

169333
### `status` - Check Deployment Status

0 commit comments

Comments
 (0)