Implement qrun package command #37

Open
opened 2026-01-03 23:45:08 +00:00 by KofTwentyTwo · 0 comments
KofTwentyTwo commented 2026-01-03 23:45:08 +00:00 (Migrated from github.com)

Part of #13

User Story

As a developer, I want to run qrun package to build a deployable OCI image from my QQQ application so that I can deploy it to any container platform.

Design

Command Interface

# Build with defaults from qrun.yaml
qrun package

# Build with specific tag
qrun package --tag myapp:v1.2.3

# Build to local Docker daemon
qrun package --docker

# Build to tarball
qrun package --local --output ./myapp.tar

# Specify base image override
qrun package --base eclipse-temurin:21-jre-alpine

# Skip tests during build
qrun package --skip-tests

Build Workflow

1. Detect project type (Maven/Gradle)
2. Run build (mvn package / gradle build)
3. Locate application JAR
4. Parse qrun.yaml for configuration
5. Build OCI image with Jib
6. Output digest and tag

Output Format

Building OCI image...
  Project: my-app
  Version: 1.2.3
  Base: eclipse-temurin:21-jre
  
Building layers:
  [1/3] Dependencies (42 JARs, 85MB)
  [2/3] Resources (12 files, 1.2MB)
  [3/3] Application (1 JAR, 4.5MB)

Image built: myapp:1.2.3
Digest: sha256:abc123...
Size: 245MB

Exit Codes

  • 0: Success
  • 1: Build failed
  • 6: Invalid configuration

Files to Create/Modify

File Action Description
PackageCommand.java Create Main command implementation
ProjectDetector.java Create Detect Maven/Gradle project
MavenBuilder.java Create Run Maven build
JarLocator.java Create Find application JAR
BuildResult.java Create Build output model

Implementation Tasks

  • Create PackageCommand with Picocli annotations
  • Implement project type detection (pom.xml vs build.gradle)
  • Implement Maven build execution
  • Implement Gradle build execution (future)
  • Implement JAR location logic (fat JAR detection)
  • Parse qrun.yaml for packaging config
  • Call JibBuilder to create image
  • Implement --tag option
  • Implement --docker option
  • Implement --local option with --output
  • Implement --base override
  • Implement --skip-tests flag
  • Add progress indicators during build
  • Handle build failures with clear messages
  • Add integration test with sample project

Acceptance Criteria

  • qrun package builds image from Maven project
  • Tag follows SemVer from pom.xml
  • Configuration loaded from qrun.yaml
  • --docker loads to local Docker daemon
  • --local creates tarball file
  • Build failures produce actionable errors
  • Progress shown during multi-step build
Part of #13 ## User Story As a **developer**, I want to run `qrun package` to build a deployable OCI image from my QQQ application so that I can deploy it to any container platform. ## Design ### Command Interface ```bash # Build with defaults from qrun.yaml qrun package # Build with specific tag qrun package --tag myapp:v1.2.3 # Build to local Docker daemon qrun package --docker # Build to tarball qrun package --local --output ./myapp.tar # Specify base image override qrun package --base eclipse-temurin:21-jre-alpine # Skip tests during build qrun package --skip-tests ``` ### Build Workflow ``` 1. Detect project type (Maven/Gradle) 2. Run build (mvn package / gradle build) 3. Locate application JAR 4. Parse qrun.yaml for configuration 5. Build OCI image with Jib 6. Output digest and tag ``` ### Output Format ``` Building OCI image... Project: my-app Version: 1.2.3 Base: eclipse-temurin:21-jre Building layers: [1/3] Dependencies (42 JARs, 85MB) [2/3] Resources (12 files, 1.2MB) [3/3] Application (1 JAR, 4.5MB) Image built: myapp:1.2.3 Digest: sha256:abc123... Size: 245MB ``` ### Exit Codes - 0: Success - 1: Build failed - 6: Invalid configuration ## Files to Create/Modify | File | Action | Description | |------|--------|-------------| | `PackageCommand.java` | Create | Main command implementation | | `ProjectDetector.java` | Create | Detect Maven/Gradle project | | `MavenBuilder.java` | Create | Run Maven build | | `JarLocator.java` | Create | Find application JAR | | `BuildResult.java` | Create | Build output model | ## Implementation Tasks - [ ] Create `PackageCommand` with Picocli annotations - [ ] Implement project type detection (pom.xml vs build.gradle) - [ ] Implement Maven build execution - [ ] Implement Gradle build execution (future) - [ ] Implement JAR location logic (fat JAR detection) - [ ] Parse `qrun.yaml` for packaging config - [ ] Call `JibBuilder` to create image - [ ] Implement `--tag` option - [ ] Implement `--docker` option - [ ] Implement `--local` option with `--output` - [ ] Implement `--base` override - [ ] Implement `--skip-tests` flag - [ ] Add progress indicators during build - [ ] Handle build failures with clear messages - [ ] Add integration test with sample project ## Acceptance Criteria - [ ] `qrun package` builds image from Maven project - [ ] Tag follows SemVer from pom.xml - [ ] Configuration loaded from `qrun.yaml` - [ ] `--docker` loads to local Docker daemon - [ ] `--local` creates tarball file - [ ] Build failures produce actionable errors - [ ] Progress shown during multi-step build
Sign in to join this conversation.