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
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PROJECT_ID=your-project-id
SYMBOL=your-topic
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.kpt-pipeline
.kpt-pipeline
.env
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,64 @@ The `gke-pubsub-websocket-adapter` uses [Workload Identity](https://cloud.google

For the default deployment, these variables are set for you in the `kubernetes-manifests/setters.yaml` file. Please modify these, and these will be rended as a part of the Skaffold pipeline.

## Using Docker Compose

For local development and testing, you can use Docker Compose to run the `gke-pubsub-websocket-adapter`. This provides a simpler setup without requiring GKE or other cloud infrastructure.

### Prerequisites

- Docker
- Docker Compose
- Google Cloud credentials configured locally

### Setup

1. Create a `.env` file in your project root:

```
PROJECT_ID=your-project-id
SYMBOL=your-topic
```

2. The `docker-compose.yml` file is already configured with the following services:
- `init-perms`: Initializes the shared volume with correct permissions
- `cron`: Handles periodic tasks
- `pulltop`: Manages Pub/Sub subscription
- `websocketd`: Serves WebSocket connections

### Running

Start all services:

```bash
docker-compose up
```

The WebSocket server will be available at `ws://localhost:8080`.

### Testing

You can test the WebSocket connection using a tool like `websocat`:

```bash
websocat ws://localhost:8080
```

Or use the built-in diagnostic page by visiting `http://localhost:8080` in your browser.

### Cleanup

Stop all services:

```bash
docker-compose down
```

To remove the shared volume data:

```bash
docker-compose down -v
```

## Known issues and enhancements

Expand Down
56 changes: 56 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: '3.8'

services:
init-perms:
image: busybox
volumes:
- data:/data
entrypoint: ["sh", "-c", "mkdir -p /data && chown -R 1000:1000 /data"]
restart: "no"

cron:
build:
context: ./cron
container_name: cron
depends_on:
- init-perms
user: "1000:1000"
environment:
- PROJECT_ID=${PROJECT_ID}
- SYMBOL=${SYMBOL}
- STREAM=/data/file
volumes:
- data:/data

pulltop:
build:
context: ./pulltop
container_name: pulltop
depends_on:
- init-perms
user: "1000:1000"
environment:
- PROJECT_ID=${PROJECT_ID}
- SYMBOL=${SYMBOL}
- STREAM=/data/file
volumes:
- data:/data

websocketd:
build:
context: ./websocketd
container_name: websocketd
depends_on:
- init-perms
user: "1000:1000"
environment:
- PROJECT_ID=${PROJECT_ID}
- SYMBOL=${SYMBOL}
- STREAM=/data/file
ports:
- "8080:8080"
volumes:
- data:/data

volumes:
data: