Skip to content

Commit

Permalink
[cicd][SRE-362]: setup pipeline ome
Browse files Browse the repository at this point in the history
  • Loading branch information
Pattarapont committed Dec 12, 2023
1 parent ce9bef7 commit 705a36e
Show file tree
Hide file tree
Showing 5 changed files with 336 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .deployment/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
OME_HOST_IP=10.100.4.1
OME_ORIGIN_PORT=9000
OME_RTMP_PROV_PORT=1935
OME_SRT_PROV_PORT=9999/udp
OME_MPEGTS_PROV_PORT=4000/udp
OME_LLHLS_STREAM_PORT=3333
OME_LLHLS_STREAM_TLS_PORT=3334
OME_WEBRTC_SIGNALLING_PORT=3333
OME_WEBRTC_SIGNALLING_TLS_PORT=3334
OME_WEBRTC_TCP_RELAY_PORT=3478
OME_WEBRTC_CANDIDATE_PORT=10000-10009/udp
11 changes: 11 additions & 0 deletions .deployment/.env.sandbox
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
OME_HOST_IP=10.100.100.13
OME_ORIGIN_PORT=9000
OME_RTMP_PROV_PORT=1935
OME_SRT_PROV_PORT=9999/udp
OME_MPEGTS_PROV_PORT=4000/udp
OME_LLHLS_STREAM_PORT=3333
OME_LLHLS_STREAM_TLS_PORT=3334
OME_WEBRTC_SIGNALLING_PORT=3333
OME_WEBRTC_SIGNALLING_TLS_PORT=3334
OME_WEBRTC_TCP_RELAY_PORT=3478
OME_WEBRTC_CANDIDATE_PORT=10000-10009/udp
39 changes: 39 additions & 0 deletions .deployment/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: "3.9"

networks:
proxy:
external: true
name: proxy-network

volumes:
ome_config:
name: ome-config
ome_edge:
name: ome-edge
ome-logs:
name: ome-logs

services:
${SERVICE_NAME}:
image: ${IMAGE_NAME}:${IMAGE_TAG}
container_name: ${SERVICE_NAME}
volumes:
- ome_config:/opt/ovenmediaengine/bin/origin_conf
- ome_dege:/opt/ovenmediaengine/bin/edge_conf
- ome_logs:/var/log/ovenmediaengine
ports:
- "9999:9999/udp"
- "3478:3478"
- "10000-10009:10000-10009/udp"
- "1935:1935" # RTMP
- "4000-4999:4000-4999/udp" # WebRTC, MPEG-TS, SRT
- "4000-4999:4000-4999/tcp" # WebRTC, MPEG-TS, SRT
- "8081:8081"
- "8080:8080" # HTTP
- "39000:9000" # HTTPS
- "3333:3333" # OVT
env_file:
- ./.env.compose
restart: unless-stopped
networks:
- proxy
137 changes: 137 additions & 0 deletions .github/workflows/development.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: CI/CD pipeline for Development
on:
push:
branches:
- develop

env:
# Manage your service
SERVICE_NAME: ome

# Defaults for docker
ENVIRONMENT_NAME: development
DOCKERFILE: ./Dockerfile
DOCKER_COMPOSE: .deployment/docker-compose.yaml
COMPOSE_ENV_FILE: .deployment/.env.development
COMPOSE_APP_ENV_FILE: .deployment/.env.compose

jobs:
dockerize:
name: Build and Push Docker image to Registry
runs-on: ubuntu-20.04
environment: development
steps:
-
name: Fetch Repository
uses: actions/checkout@v4
with:
fetch-depth: 2
-
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
name: Setup QEMU
uses: docker/[email protected]
-
name: Setup Docker Buildx
uses: docker/[email protected]
-
name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Setup Lowercase Repository
id: repository
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.repository }}
-
name: Set version output
id: vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
-
name: Build and Push Container image
uses: docker/build-push-action@v5
with:
file: ${{ env.DOCKERFILE }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
target: release
tags: |
ghcr.io/${{ steps.repository.outputs.lowercase }}:develop
ghcr.io/${{ steps.repository.outputs.lowercase }}:${{ env.sha_short }}
deploy:
name: Deploy Development Service
runs-on: [self-hosted, linux, x64, staging, hybiot, internal]
environment: development
needs:
- dockerize
steps:
-
name: Setup Lowercase Repository
id: repository
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.repository }}
-
name: Fetch Repository
uses: actions/checkout@v4
with:
fetch-depth: 2
-
name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Set version output
id: vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
-
name: Create env Docker-Compose
run: |
touch ${{ env.COMPOSE_APP_ENV_FILE }}
cat .deployment/.env.${{ env.COMPOSE_ENV_FILE }} >> ${{ env.COMPOSE_APP_ENV_FILE }}
env:
IMAGE_NAME: ghcr.io/${{ steps.repository.outputs.lowercase }}
IMAGE_TAG: ${{ env.sha_short }}
SERVICE_NAME: ${{ env.SERVICE_NAME }}
-
name: Docker-Compose Deploy
uses: alex-ac/github-action-ssh-docker-compose@master
with:
ssh_host: "10.100.4.1"
ssh_user: "hybiot"
ssh_port: "22"
ssh_private_key: ${{ secrets.PIPELINE_DEPLOY_KEY }}
docker_compose_prefix: ${{ env.SERVICE_NAME }}
docker_compose_filename: ${{ env.DOCKER_COMPOSE }}

notify:
name: Discord Notification
runs-on: ubuntu-20.04
needs:
- dockerize
- deploy
if: ${{ always() }}
steps:
- name: Notify
uses: nobrayner/discord-webhook@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
discord-webhook: ${{ secrets.ACTIONS_DISCORD_WEBHOOK }}
title: '{{STATUS}} : ${{ github.workflow }}'
description: '[${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})'
include-details: 'true'
color-success: '#1a7f37'
color-failure: '#cf222e'
color-cancelled: '#7c848d'
138 changes: 138 additions & 0 deletions .github/workflows/sandbox.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: CI/CD pipeline for Sandbox
on:
push:
branches:
- develop
- feature/SRE-362-github-actions

env:
# Manage your service
SERVICE_NAME: ome

# Defaults for docker
ENVIRONMENT_NAME: sandbox
DOCKERFILE: ./Dockerfile
DOCKER_COMPOSE: .deployment/docker-compose.yaml
COMPOSE_ENV_FILE: .deployment/.env.sandbox
COMPOSE_APP_ENV_FILE: .deployment/.env.compose

jobs:
dockerize:
name: Build and Push Docker image to Registry
runs-on: ubuntu-20.04
environment: sandbox
steps:
-
name: Fetch Repository
uses: actions/checkout@v4
with:
fetch-depth: 2
-
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
name: Setup QEMU
uses: docker/[email protected]
-
name: Setup Docker Buildx
uses: docker/[email protected]
-
name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Setup Lowercase Repository
id: repository
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.repository }}
-
name: Set version output
id: vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
-
name: Build and Push Container image
uses: docker/build-push-action@v5
with:
file: ${{ env.DOCKERFILE }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
target: release
tags: |
ghcr.io/${{ steps.repository.outputs.lowercase }}:develop
ghcr.io/${{ steps.repository.outputs.lowercase }}:${{ env.sha_short }}
deploy:
name: Deploy Sandbox Service
runs-on: [self-hosted, linux, x64, staging, hybiot, internal]
environment: sandbox
needs:
- dockerize
steps:
-
name: Setup Lowercase Repository
id: repository
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.repository }}
-
name: Fetch Repository
uses: actions/checkout@v4
with:
fetch-depth: 2
-
name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Set version output
id: vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
-
name: Create env Docker-Compose
run: |
touch ${{ env.COMPOSE_APP_ENV_FILE }}
cat .deployment/.env.${{ env.COMPOSE_ENV_FILE }} >> ${{ env.COMPOSE_APP_ENV_FILE }}
env:
IMAGE_NAME: ghcr.io/${{ steps.repository.outputs.lowercase }}
IMAGE_TAG: ${{ env.sha_short }}
SERVICE_NAME: ${{ env.SERVICE_NAME }}
-
name: Docker-Compose Deploy
uses: alex-ac/github-action-ssh-docker-compose@master
with:
ssh_host: "10.100.100.12"
ssh_user: "root"
ssh_port: "22"
ssh_private_key: ${{ secrets.PIPELINE_DEPLOY_KEY }}
docker_compose_prefix: ${{ env.SERVICE_NAME }}
docker_compose_filename: ${{ env.DOCKER_COMPOSE }}

notify:
name: Discord Notification
runs-on: ubuntu-20.04
needs:
- dockerize
- deploy
if: ${{ always() }}
steps:
- name: Notify
uses: nobrayner/discord-webhook@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
discord-webhook: ${{ secrets.ACTIONS_DISCORD_WEBHOOK }}
title: '{{STATUS}} : ${{ github.workflow }}'
description: '[${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})'
include-details: 'true'
color-success: '#1a7f37'
color-failure: '#cf222e'
color-cancelled: '#7c848d'

0 comments on commit 705a36e

Please sign in to comment.