This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from wireapp/staging
Release
- Loading branch information
Showing
31 changed files
with
928 additions
and
465 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ Recording Test.html | |
recording/ | ||
data/ | ||
target/ | ||
libs/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
Oops, something went wrong.