Skip to content

Commit

Permalink
Merge pull request #18 from wireapp/staging
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
LukasForst authored Oct 20, 2022
2 parents 991a1e9 + cb73a51 commit 9430d31
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 151 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
# Setup gcloud CLI
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@master
uses: google-github-actions/setup-gcloud@v0
with:
service_account_email: [email protected]
service_account_key: ${{ secrets.GKE_SA_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
# Setup gcloud CLI
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@master
uses: google-github-actions/setup-gcloud@v0
with:
service_account_email: [email protected]
service_account_key: ${{ secrets.GKE_SA_KEY }}
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM adoptopenjdk/openjdk11:jdk-11.0.6_10-alpine AS build
FROM adoptopenjdk/openjdk11:alpine AS build
LABEL description="Wire Poll Bot"
LABEL project="wire-bots:polls"

Expand All @@ -21,7 +21,7 @@ COPY . $PROJECT_ROOT
RUN ./gradlew distTar --no-daemon

# Runtime
FROM adoptopenjdk/openjdk11:jre-11.0.6_10-alpine
FROM adoptopenjdk/openjdk11:alpine-jre

ENV APP_ROOT /app
WORKDIR $APP_ROOT
Expand Down
18 changes: 3 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,10 @@ up:
docker-compose up -d db && docker-compose up bot

docker-run:
docker run --rm -p 8080:8080 lukaswire/polls
docker run --rm -p 8080:8080 quay.io/wire/poll-bot

docker-build:
docker build -t lukaswire/polls:latest .
docker build -t quay.io/wire/poll-bot:latest .

publish: docker-build
docker push lukaswire/polls:latest

kube-deploy:
kubectl delete pod -l name=poll -n staging

kube-logs:
kubectl logs --follow -l name=poll -n staging

kube-describe:
kubectl describe pods -l name=poll -n staging

kube-prod-logs:
kubectl logs --follow -l name=poll -n prod
docker push quay.io/wire/poll-bot:latest
51 changes: 34 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,37 @@ Service code to enable Poll bot in your team:
## Commands
Basic usage
* `/poll "Question" "Option 1" "Option 2"` will create poll
* `/stats` will send result of the last poll in the conversation
* `/stats` will send result of the **latest** poll in the conversation
* `/help` to show help
* `/version` prints the current version of the poll bot


## Dev Stack
## Technologies used
* HTTP Server - [Ktor](https://ktor.io/)
* HTTP Client - [Apache](https://ktor.io/clients/http-client/engines.html) under [Ktor](https://ktor.io/)
* Dependency Injection - [Kodein](https://github.com/Kodein-Framework/Kodein-DI)
* Build system - [Gradle](https://gradle.org/)
* Communication with [Wire](https://wire.com/) - [Roman](https://github.com/dkovacevic/roman)

Bot can connect to web socket stream or can use webhook from Roman.
Bot is using webhooks coming from Roman, for that, the bot needs to have public URL or IP address.

## Usage
* To run the application simply execute `make run` or `./gradlew run`.
* To run the application inside the docker compose environment run `make up`

For more details see [Makefile](Makefile).
* The bot needs Postgres database up & running - we use one in [docker-compose.yml](docker-compose.yml), to start it up, you can use
command `make db`.
* To run the application execute `make run` or `./gradlew run`.
* To run the application inside the docker compose environment run `make up`.

For more details see [Makefile](Makefile).

## Docker Images
Poll bot has public [docker image](https://hub.docker.com/r/lukaswire/polls).

Poll bot has public [docker image](https://quay.io/wire/poll-bot).
```bash
lukaswire/polls
quay.io/wire/poll-bot
```
Tag `latest` is current master branch - each commit is build and tagged as `latest`.
[Releases](https://github.com/wireapp/poll-bot/releases) have then images with corresponding tag.

Tag `latest` is the latest release. [Releases](https://github.com/wireapp/poll-bot/releases) have then images with corresponding tag, so you
can always roll back. Tag `staging` is build from the latest commit in `staging` branch.


## Bot configuration
Expand Down Expand Up @@ -69,12 +73,9 @@ Configuration is currently being loaded from the environment variables.
* Token which is used for the auth of proxy.
*/
const val SERVICE_TOKEN = "SERVICE_TOKEN"

/**
* Key for connecting to the web socket of the proxy.
*/
const val APP_KEY = "APP_KEY"
/**
* Domain used for sending the messages from the bot to proxy eg. "https://proxy.services.zinfra.io"
* Domain used for sending the messages from the bot to proxy eg. "https://proxy.services.zinfra.io/api"
*/
const val PROXY_DOMAIN = "PROXY_DOMAIN"
```
Expand All @@ -95,6 +96,22 @@ DB_USER=
DB_PASSWORD=
DB_URL=
SERVICE_TOKEN=
APP_KEY=
PROXY_DOMAIN=
```

Such configuration can look for example like that:

```bash
# database
POSTGRES_USER=wire-poll-bot
POSTGRES_PASSWORD=super-secret-wire-pwd
POSTGRES_DB=poll-bot

# application
DB_USER=wire-poll-bot
DB_PASSWORD=super-secret-wire-pwd
DB_URL=jdbc:postgresql://db:5432/poll-bot
SERVICE_TOKEN=x6jsd5vets967dsA01dz1cOl
APP_KEY=eyJhbGciOiJIUzM4NCJ9.......
PROXY_DOMAIN=https://proxy.services.zinfra.io/api
```
19 changes: 13 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
kotlin("jvm") version "1.5.0"
kotlin("jvm") version "1.5.30"
application
distribution
id("net.nemerosa.versioning") version "2.14.0"
Expand All @@ -22,10 +22,10 @@ dependencies {
// stdlib
implementation(kotlin("stdlib-jdk8"))
// extension functions
implementation("pw.forst", "katlib", "2.0.1")
implementation("pw.forst", "katlib", "2.0.3")

// Ktor server dependencies
val ktorVersion = "1.5.4"
val ktorVersion = "1.6.3"
implementation("io.ktor", "ktor-server-core", ktorVersion)
implementation("io.ktor", "ktor-server-netty", ktorVersion)
implementation("io.ktor", "ktor-jackson", ktorVersion)
Expand Down Expand Up @@ -58,7 +58,7 @@ dependencies {
// database
implementation("org.postgresql", "postgresql", "42.2.20")

val exposedVersion = "0.31.1"
val exposedVersion = "0.33.1"
implementation("org.jetbrains.exposed", "exposed-core", exposedVersion)
implementation("org.jetbrains.exposed", "exposed-dao", exposedVersion)
implementation("org.jetbrains.exposed", "exposed-jdbc", exposedVersion)
Expand All @@ -70,11 +70,18 @@ dependencies {
}

tasks {
val jvmTarget = "1.8"
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.jvmTarget = jvmTarget
}
compileJava {
targetCompatibility = jvmTarget
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.jvmTarget = jvmTarget
}
compileTestJava {
targetCompatibility = jvmTarget
}

distTar {
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
- db

db:
image: postgres:13.1
image: postgres:13
container_name: poll-bot-db
env_file: .env
ports:
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 9430d31

Please sign in to comment.