Skip to content

Commit

Permalink
Gradle tasks to start playground locally (apache#23939) (apache#23941)
Browse files Browse the repository at this point in the history
* Gradle tasks to start playground locally (apache#23939)

* Update task descriptions (apache#23939)

* Add local backend running to README (apache#23939)

* Clean up README (apache#23939)
  • Loading branch information
alexeyinkin authored Dec 15, 2022
1 parent 9347e06 commit aa6cc16
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 5 deletions.
38 changes: 33 additions & 5 deletions playground/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,47 @@ cd beam

## Run local environment using docker compose

```
### Router only

Start:

```bash
cd beam
./gradlew playground:backend:containers:router:dockerComposeLocalUp
```

## Stop containers and removes containers created by dockerComposeLocalUp
Stop:

```
```bash
cd beam
./gradlew playground:backend:containers:router:dockerComposeLocalDown
```

## Run the method to remove unused code snippets from the Cloud Datastore. Unused snippets are snippets that are out of date. If the last visited date property less or equals than the current date minus dayDiff parameter then a snippet is out of date
### Router, runners, and frontend

1. Edit `/playground/frontend/lib/config.g.dart` to set your local backend host and ports
found in `/playground/docker-compose.local.yaml`.
2. To start, run:

```bash
cd beam
./gradlew playground:dockerComposeLocalUp
```

3. To stop, run:

```bash
cd beam
./gradlew playground:dockerComposeLocalDown
```

If you do not need particular runners, comment out:
1. Dependencies on them in `/playground/build.gradle.kts` in `dockerComposeLocalUp` task.
2. Their Docker image configurations in `/playground/docker-compose.local.yaml`.

## Removing old snippets

Run the method to remove unused code snippets from the Cloud Datastore. Unused snippets are snippets that are out of date. If the last visited date property less or equals than the current date minus dayDiff parameter then a snippet is out of date

```
cd beam
Expand All @@ -91,4 +119,4 @@ cd beam
# Deployment

See [terraform](./terraform/README.md) for details on how to build and deploy
the application and its dependent infrastructure.
the application and its dependent infrastructure.
31 changes: 31 additions & 0 deletions playground/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,34 @@ task("lintProto") {
}
}
}

task("dockerComposeLocalUp") {
dependsOn(":playground:backend:containers:router:docker")
dependsOn(":playground:backend:containers:go:docker")
dependsOn(":playground:backend:containers:java:docker")
dependsOn(":playground:backend:containers:python:docker")
dependsOn(":playground:backend:containers:scio:docker")
dependsOn(":playground:frontend:docker")

group = "build"
description = "Start Playground backend and frontend locally"

doLast {
exec {
executable("docker-compose")
args("-f", "docker-compose.local.yaml", "up", "-d")
}
}
}

task("dockerComposeLocalDown") {
group = "build"
description = "Stop Playground backend and frontend locally"

doLast {
exec {
executable("docker-compose")
args("-f", "docker-compose.local.yaml", "down")
}
}
}
100 changes: 100 additions & 0 deletions playground/docker-compose.local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

version: "2"

services:
redis:
image: redis:7.0.4-alpine
ports:
- "6379:6379"

datastore:
build: "./backend/containers/router/datastore"
environment:
DATASTORE_PROJECT_ID: test
DATASTORE_LISTEN_ADDRESS: 0.0.0.0:8081
ports:
- "8081:8081"

router:
image: apache/beam_playground-backend-router
environment:
GOOGLE_CLOUD_PROJECT: test
DATASTORE_EMULATOR_HOST: datastore:8081
CACHE_TYPE: remote
CACHE_ADDRESS: redis:6379
SDK_CONFIG: /opt/playground/backend/sdks-emulator.yaml
SERVER_PORT: 8082
ports:
- "8082:8082"
depends_on:
- redis
- datastore

go_runner:
image: apache/beam_playground-backend-go
environment:
GOOGLE_CLOUD_PROJECT: test
CACHE_TYPE: remote
CACHE_ADDRESS: redis:6379
SERVER_PORT: 8084
ports:
- "8084:8084"
depends_on:
- redis

java_runner:
image: apache/beam_playground-backend-java
environment:
GOOGLE_CLOUD_PROJECT: test
CACHE_TYPE: remote
CACHE_ADDRESS: redis:6379
SERVER_PORT: 8086
ports:
- "8086:8086"
depends_on:
- redis

python_runner:
image: apache/beam_playground-backend-python
environment:
GOOGLE_CLOUD_PROJECT: test
CACHE_TYPE: remote
CACHE_ADDRESS: redis:6379
SERVER_PORT: 8088
ports:
- "8088:8088"
depends_on:
- redis

scio_runner:
image: apache/beam_playground-backend-scio
environment:
GOOGLE_CLOUD_PROJECT: test
CACHE_TYPE: remote
CACHE_ADDRESS: redis:6379
SERVER_PORT: 8090
ports:
- "8090:8090"
depends_on:
- redis

frontend:
image: apache/beam_playground-frontend
ports:
- "1234:8080"
depends_on:
- router

0 comments on commit aa6cc16

Please sign in to comment.