Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Main Branch CI

on:
push:
branches:
- main

permissions:
contents: read
packages: write

jobs:
publish:
name: Publish Docker Image
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Set up Java 17
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build and push Docker image
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Build and push with Jib
./gradlew jib --no-daemon \
-Djib.to.tags=latest,${{ github.sha }}

- name: Docker Image Summary
run: |
echo "### Docker Image Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Image:** ghcr.io/geico/cassandra-sql" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
echo "- \`latest\`" >> $GITHUB_STEP_SUMMARY
echo "- \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Pull command:**" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
echo "docker pull ghcr.io/geico/cassandra-sql:latest" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
37 changes: 37 additions & 0 deletions .github/workflows/pr-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Pull Request CI

on:
pull_request:
branches:
- main

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Set up Java 17
uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: "17"

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build
run: ./gradlew build -x test --no-daemon
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,75 @@ See [docs/DEMO_ECOMMERCE.md](docs/DEMO_ECOMMERCE.md) for detailed demo walkthrou

---

## Docker Deployment

Docker images are automatically built and published to GitHub Container Registry on every merge to the `main` branch.

### Pulling the Docker Image

```bash
docker pull ghcr.io/geico/cassandra-sql:latest
```

### Running with Docker

```bash
# Run the container
docker run -d \
--name cassandra-sql \
-p 8080:8080 \
-p 5432:5432 \
-e CASSANDRA_CONTACT_POINTS=host.docker.internal \
ghcr.io/geico/cassandra-sql:latest
```

**Exposed Ports**:
- `8080`: REST API endpoint
- `5432`: PostgreSQL wire protocol server

**Environment Variables**:
- `CASSANDRA_CONTACT_POINTS`: Cassandra server address (default: localhost)
- `CASSANDRA_PORT`: Cassandra port (default: 9042)
- `CASSANDRA_KEYSPACE`: Keyspace name (default: cassandra_sql)
- `POSTGRES_PORT`: PostgreSQL protocol port (default: 5432)

**Memory Configuration**:

Java 17 automatically detects container memory limits. Configure memory using Docker:

```bash
# Limit container to 2GB
docker run --memory=2g ghcr.io/geico/cassandra-sql:latest

# Or set JVM heap size directly
docker run -e JAVA_TOOL_OPTIONS="-Xmx2g" ghcr.io/geico/cassandra-sql:latest
```

### Connecting to the Docker Container

Once running, you can connect using psql:

```bash
psql -h localhost -p 5432 -d cassandra_sql
```

Or access the REST API:

```bash
curl -X POST http://localhost:8080/api/sql/execute \
-H "Content-Type: application/json" \
-d '{"sql": "SELECT 1"}'
```

### Image Details

- **Base Image**: eclipse-temurin:17-jre-alpine
- **Size**: ~150-200MB
- **Architecture**: amd64, arm64
- **Registry**: GitHub Container Registry (ghcr.io)

---

## SQL Feature Support

See [docs/SQL_GRAMMAR.md](docs/SQL_GRAMMAR.md) for detailed implementation status.
Expand Down
44 changes: 44 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.1.5'
id 'io.spring.dependency-management' version '1.1.3'
id 'com.google.cloud.tools.jib' version '3.4.5'
}

group = 'org.cassandrasql'
Expand Down Expand Up @@ -195,3 +196,46 @@ task buildWithTests {
}
}

// Jib configuration for Docker container building
jib {
from {
image = 'eclipse-temurin:17-jre-alpine'
platforms {
platform {
architecture = 'amd64'
os = 'linux'
}
platform {
architecture = 'arm64'
os = 'linux'
}
}
}

to {
image = 'ghcr.io/geico/cassandra-sql'
tags = [version, 'latest']
auth {
username = System.getenv('GITHUB_ACTOR') ?: 'username'
password = System.getenv('GITHUB_TOKEN') ?: 'token'
}
}

container {
jvmFlags = [
'-XX:+UseG1GC',
'-XX:MaxGCPauseMillis=100'
]
ports = ['8080', '5432']
labels = [
'org.opencontainers.image.title': 'Cassandra SQL',
'org.opencontainers.image.description': 'SQL layer for Apache Cassandra with PostgreSQL wire protocol support',
'org.opencontainers.image.version': version,
'org.opencontainers.image.source': 'https://github.com/geico/cassandra-sql',
'org.opencontainers.image.licenses': 'Apache-2.0'
]
creationTime = 'USE_CURRENT_TIMESTAMP'
format = 'OCI'
}
}