Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Release #29

Merged
merged 52 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
9b82f8f
WIP
dkovacevic Sep 13, 2022
b5c9bb6
WIP
dkovacevic Sep 13, 2022
14fdad9
it compiles
dkovacevic Sep 13, 2022
5e892b4
Config
dkovacevic Sep 22, 2022
ef05907
Fixed tests, bumped deps
dkovacevic Sep 22, 2022
ece8fae
Fixed dockerfile
dkovacevic Sep 22, 2022
c017544
Add docker compose based deployment (#24)
amitsagtani97 Sep 22, 2022
7c1b1ab
Dep bump
dkovacevic Sep 22, 2022
ce9e744
workflows
dkovacevic Sep 27, 2022
e584901
kibana for txt
dkovacevic Sep 27, 2022
a7e50a2
Added missing java file
dkovacevic Oct 6, 2022
a8abfd5
Bump lithium from 3.4.0 to 3.4.2 (#26)
dependabot[bot] Oct 10, 2022
2312273
Update docker-compose.yml
dkovacevic Oct 11, 2022
235d2e9
Update docker-compose.yml
dkovacevic Oct 11, 2022
7cbaa8a
add deployment pipelines
LukasForst Oct 15, 2022
9e114af
fix service name for the deployment
LukasForst Oct 15, 2022
5b4291d
Allow only bot owners to run commands
dkovacevic Oct 26, 2022
f6a69db
Merge branch 'staging' of https://github.com/wireapp/recording-bot in…
dkovacevic Oct 26, 2022
fc59024
logs
dkovacevic Oct 26, 2022
3a83756
less logs
dkovacevic Oct 26, 2022
7ff0a02
override readResource in ImagesBundle
dkovacevic Oct 26, 2022
1e87881
override readResource in ImagesBundle
dkovacevic Oct 26, 2022
7fb4c14
override readResource in ImagesBundle
dkovacevic Oct 26, 2022
536568d
Logging for download assets
dkovacevic Oct 27, 2022
a9dc8bf
Lithium 3.4.3
dkovacevic Oct 27, 2022
7dae6b4
FileAssets
dkovacevic Oct 27, 2022
98f0b54
FileAssets uploads
dkovacevic Oct 27, 2022
5288ffd
more logs
dkovacevic Oct 27, 2022
12cd900
Lithium 3.4.4 with fixed AssetKey class
dkovacevic Oct 27, 2022
fd3c26b
Hash asset keys
dkovacevic Oct 28, 2022
55cadd2
SHA 256 Hash asset keys
dkovacevic Oct 28, 2022
fe33d5c
obfuscate conversation id
dkovacevic Oct 28, 2022
39a2aa9
Dont url encode the hash
dkovacevic Oct 31, 2022
5e76482
Added salt
dkovacevic Oct 31, 2022
e598a2b
Store all assets for the conv in a separate dire
dkovacevic Oct 31, 2022
5a07114
File path in Collector
dkovacevic Oct 31, 2022
d078bcf
Delete asset files upon /private
dkovacevic Oct 31, 2022
0cba6d3
ImageBundle media type
dkovacevic Nov 1, 2022
d5e0ea3
imply meme type from the asset content
dkovacevic Nov 1, 2022
a8e3bc1
FileAttachments
dkovacevic Nov 1, 2022
76b745a
FileAttachments
dkovacevic Nov 1, 2022
981c429
Disabled markdowns
dkovacevic Nov 1, 2022
7eb7681
more logging
dkovacevic Nov 1, 2022
b049301
Lithium 3.4.5
dkovacevic Nov 1, 2022
0710ee9
BaseUrl for PDF
dkovacevic Nov 1, 2022
5b5beca
NPE in /pdf
dkovacevic Nov 2, 2022
c828fc5
Enabled markdown
dkovacevic Nov 2, 2022
67006bc
template
dkovacevic Nov 2, 2022
540c06c
sanitizeUrls(true)
dkovacevic Nov 9, 2022
b5acac0
Display attachment name
dkovacevic Nov 10, 2022
a06282b
Merge branch 'master' into staging
dkovacevic Nov 11, 2022
449af2c
Pom.xml
dkovacevic Nov 11, 2022
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
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on:
push:
branches-ignore:
- master
- staging

pull_request:

jobs:
docker-build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

# setup docker actions https://github.com/docker/build-push-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build image
id: docker_build
uses: docker/build-push-action@v2
with:
# https://github.com/docker/build-push-action/issues/220
context: .
tags: wire/ci-test-image
push: false
117 changes: 117 additions & 0 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Release Pipeline

on:
release:
types: published

env:
# set docker image for the service - i.e. "wire-bot/poll"
DOCKER_IMAGE: wire-bot/recording-bot
# name of the service in the Dagobah - the value for label name, i.e. "polls"
SERVICE_NAME: recording

jobs:
deploy:
name: Build and deploy service
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- name: Set Release Version
# use latest tag as release version
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV

# extract metadata for labels https://github.com/crazy-max/ghaction-docker-meta
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: eu.gcr.io/${{ env.DOCKER_IMAGE }}

# setup docker actions https://github.com/docker/build-push-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# login to GCR repo
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: eu.gcr.io
username: _json_key
password: ${{ secrets.GCR_ACCESS_JSON }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
# push only if this is indeed a taged release
push: ${{ startsWith(github.ref, 'refs/tags/') }}
build-args: |
release_version=${{ env.RELEASE_VERSION }}
# Checkout our Kubernetes configuration
- name: Checkout Rubicon
uses: actions/checkout@v2
with:
repository: zinfra/rubicon
# currently main branch is develop
ref: develop
path: rubicon
# private repo so use different git token
token: ${{ secrets.RUBICON_GIT_TOKEN }}

# Update version to the one that was just built
- name: Change Version in Rubicon
env:
IMAGE: ${{ env.DOCKER_IMAGE }}
SERVICE: ${{ env.SERVICE_NAME }}
VERSION: ${{ env.RELEASE_VERSION }}
run: |
# go to directory with configuration
cd "rubicon/prod/services/$SERVICE"
# escape literals for the sed and set output with GCR
export SED_PREPARED=$(echo $IMAGE | awk '{ gsub("/", "\\/", $1); print "eu.gcr.io\\/"$1 }')
# update final yaml
sed -i".bak" "s/image: $SED_PREPARED.*/image: $SED_PREPARED:$VERSION/g" "$SERVICE.yaml"
# delete bakup file
rm "$SERVICE.yaml.bak"
# Setup gcloud CLI
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
service_account_email: [email protected]
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: wire-bot
export_default_credentials: true

# Configure Docker to use the gcloud command-line tool
- name: Configure Docker Google cloud
run: |
gcloud --quiet auth configure-docker
# Get the GKE credentials so we can deploy to the cluster
- name: Obtain k8s credentials
env:
GKE_CLUSTER: anayotto
GKE_ZONE: europe-west1-c
run: |
gcloud container clusters get-credentials "$GKE_CLUSTER" --zone "$GKE_ZONE"
# K8s is set up, deploy the app
- name: Deploy the Service
env:
SERVICE: ${{ env.SERVICE_NAME }}
run: |
kubectl apply -f "rubicon/prod/services/$SERVICE/$SERVICE.yaml"
# Commit all data to Rubicon and open PR
- name: Create Rubicon Pull Request
uses: peter-evans/create-pull-request@v3
with:
path: rubicon
branch: ${{ env.SERVICE_NAME }}-release
token: ${{ secrets.RUBICON_GIT_TOKEN }}
labels: version-bump, automerge
title: ${{ env.SERVICE_NAME }} release ${{ env.RELEASE_VERSION }}
commit-message: ${{ env.SERVICE_NAME }} version bump to ${{ env.RELEASE_VERSION }}
body: |
This is automatic version bump from the pipeline.
85 changes: 85 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Staging Deployment

on:
push:
branches:
- staging

env:
# set docker image for the service - i.e. "wire-bot/poll"
DOCKER_IMAGE: wire-bot/recording-bot
# name of the service in the Dagobah - the value for label name, i.e. "polls"
SERVICE_NAME: recording

jobs:
publish:
name: Deploy to staging
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

# use latest tag as release version in the docker container
- name: Set Release Version
run: echo "RELEASE_VERSION=${GITHUB_SHA}" >> $GITHUB_ENV

# extract metadata for labels https://github.com/crazy-max/ghaction-docker-meta
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: eu.gcr.io/${{ env.DOCKER_IMAGE }}

# setup docker actions https://github.com/docker/build-push-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# login to GCR repo
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: eu.gcr.io
username: _json_key
password: ${{ secrets.GCR_ACCESS_JSON }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
push: true
build-args: |
release_version=${{ env.RELEASE_VERSION }}

# Setup gcloud CLI
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
service_account_email: [email protected]
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: wire-bot
export_default_credentials: true

# Configure Docker to use the gcloud command-line tool
- name: Configure Docker Google cloud
run: |
gcloud --quiet auth configure-docker

# Get the GKE credentials so we can deploy to the cluster
- name: Obtain k8s credentials
env:
GKE_CLUSTER: dagobah
GKE_ZONE: europe-west1-c
run: |
gcloud container clusters get-credentials "$GKE_CLUSTER" --zone "$GKE_ZONE"

# K8s is set up, deploy the app
- name: Deploy the Service
env:
SERVICE: ${{ env.SERVICE_NAME }}
run: |
kubectl delete pod -l app=$SERVICE -n staging
kubectl describe pod -l app=$SERVICE -n staging


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Recording Test.html
recording/
data/
target/
libs/
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

27 changes: 19 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM maven:3.6.3-jdk-8-slim AS build
FROM maven:3-openjdk-11 AS build
LABEL description="Wire Recording bot"
LABEL project="wire-bots:recording"

Expand All @@ -8,15 +8,14 @@ WORKDIR /app
COPY pom.xml ./
RUN mvn verify --fail-never -U

# build stuff
# build
COPY . ./
RUN mvn -Dmaven.test.skip=true package

FROM dejankovacevic/bots.runtime:2.10.3

COPY --from=build /app/target/recording.jar /opt/recording/recording.jar
COPY --from=build /app/recording.yaml /etc/recording/recording.yaml
# runtime stage
FROM wirebot/runtime:1.2.0

RUN mkdir /opt/recording
RUN mkdir /opt/recording/assets
RUN mkdir /opt/recording/avatars
RUN mkdir /opt/recording/html
Expand All @@ -25,6 +24,18 @@ COPY --from=build /app/src/main/resources/assets/* /opt/recording/assets/

WORKDIR /opt/recording

EXPOSE 8080 8081 8082
EXPOSE 8080 8081

# Copy configuration
COPY recording.yaml /opt/recording/

# Copy built target
COPY --from=build /app/target/recording.jar /opt/recording/

# create version file
ARG release_version=development
ENV RELEASE_FILE_PATH=/opt/recording/release.txt
RUN echo $release_version > $RELEASE_FILE_PATH

CMD ["sh", "-c","/usr/bin/java -Djava.library.path=/opt/wire/lib -jar recording.jar server /etc/recording/recording.yaml"]
EXPOSE 8080 8081
ENTRYPOINT ["java", "-jar", "recording.jar", "server", "/opt/recording/recording.yaml"]
9 changes: 5 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
docker build -t $DOCKER_USERNAME/recording-bot:1.0.0 .
docker push $DOCKER_USERNAME/recording-bot
kubectl delete pod -l name=recording -n prod
kubectl get pods -l name=recording -n prod
TAG=1.0.1
NAME=recording-bot

docker build -t $DOCKER_USERNAME/$NAME:$TAG .
docker push $DOCKER_USERNAME/$NAME:$TAG

70 changes: 70 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
version: '3.8'
services:
app:
build:
context: .
dockerfile: Dockerfile
args:
- release_version=docker-compose
image: recordingbot
ports:
- 8080:8080
- 8081:8081
environment:
# put here the token used for testing
- SERVICE_TOKEN=some-service-token-from-BE
# - WIRE_API_HOST=
- PUBLIC_URL=http://localhost:8080
# local database
- DB_URL=jdbc:postgresql://db:5432/recording
- DB_USER=recording
- DB_PASSWORD=recording
- APPENDER_TYPE=json-console
depends_on:
- db
- elasticsearch
- kibana
- filebeat

db:
image: postgres:13
# just for local development
environment:
- POSTGRES_USER=recording
- POSTGRES_PASSWORD=recording
- POSTGRES_DB=recording
ports:
- 5432:5432
volumes:
- recording-db:/var/lib/postgresql/data/

elasticsearch:
container_name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:7.11.0
environment:
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
- "discovery.type=single-node"
ports:
- 9200:9200

kibana:
container_name: kb-container
image: docker.elastic.co/kibana/kibana:7.11.0
environment:
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
- ELASTICSEARCH_URL=http://elasticsearch:9200
depends_on:
- elasticsearch
ports:
- 5601:5601

filebeat:
image: "docker.elastic.co/beats/filebeat:7.2.0"
user: root
volumes:
- ./filebeat.yml:/usr/share/filebeat/filebeat.yml:ro
- /var/lib/docker:/var/lib/docker:ro
- /var/run/docker.sock:/var/run/docker.sock

volumes:
recording-db:
Loading