Skip to content

Commit

Permalink
[chore][SRE-362]: setup resource limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Pattarapon Theanthong committed Dec 13, 2023
1 parent 705a36e commit 42c4605
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 41 deletions.
31 changes: 20 additions & 11 deletions .deployment/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,42 @@ networks:

volumes:
ome_config:
name: ome-config
name: ome_config
ome_edge:
name: ome-edge
ome-logs:
name: ome-logs
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_edge:/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
#- "39000:9000" # HTTPS
- "8081:8081"
- "3333:3333" # OVT
#- "9999:9999/udp"
#- "10000-10009:10000-10009/udp"
# - "4000-4999:4000-4999/udp" # WebRTC, MPEG-TS, SRT
# - "4000-4999:4000-4999/tcp" # WebRTC, MPEG-TS, SRT
env_file:
- ./.env.compose
restart: unless-stopped
networks:
- proxy
deploy:
resources:
reservations:
cpus: '1.5'
memory: 2048M
limits:
cpus: '2'
memory: 3072M

36 changes: 21 additions & 15 deletions .github/workflows/development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ env:
ENVIRONMENT_NAME: development
DOCKERFILE: ./Dockerfile
DOCKER_COMPOSE: .deployment/docker-compose.yaml
COMPOSE_ENV_FILE: .deployment/.env.development
DOCKER_COMPOSE_DEPLOY: .deployment/compose-deploy.yaml
COMPOSE_ENV_FILE: .deployment/.env
COMPOSE_APP_ENV_FILE: .deployment/.env.compose

jobs:
dockerize:
name: Build and Push Docker image to Registry
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
environment: development
steps:
-
Expand Down Expand Up @@ -68,7 +69,7 @@ jobs:
deploy:
name: Deploy Development Service
runs-on: [self-hosted, linux, x64, staging, hybiot, internal]
runs-on: [self-hosted, linux, x64, ome-dev, hybiot, internal]
environment: development
needs:
- dockerize
Expand Down Expand Up @@ -99,22 +100,27 @@ jobs:
-
name: Create env Docker-Compose
run: |
touch ${{ env.COMPOSE_ENV_FILE }}
echo '' > ${{ env.COMPOSE_ENV_FILE }}
echo IMAGE_NAME=ghcr.io/${{ steps.repository.outputs.lowercase }} >> ${{ env.COMPOSE_ENV_FILE }}
echo IMAGE_TAG=${{ env.sha_short }} >> ${{ env.COMPOSE_ENV_FILE }}
echo SERVICE_NAME=${{ env.SERVICE_NAME }} >> ${{ env.COMPOSE_ENV_FILE }}
touch ${{ env.COMPOSE_APP_ENV_FILE }}
cat .deployment/.env.${{ env.COMPOSE_ENV_FILE }} >> ${{ env.COMPOSE_APP_ENV_FILE }}
cat .deployment/.env.${{ env.ENVIRONMENT_NAME }} >> ${{ env.COMPOSE_APP_ENV_FILE }}
envsubst < ${{ env.DOCKER_COMPOSE }} > ${{ env.DOCKER_COMPOSE_DEPLOY }}
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 }}
-
name: Starting docker compose services
run: |
docker compose -f ${{ env.DOCKER_COMPOSE_DEPLOY }} pull
docker compose -f ${{ env.DOCKER_COMPOSE_DEPLOY }} up -d
docker ps -a
env:
COMPOSE_HTTP_TIMEOUT: 600
SERVICE_NAME: ${{ env.SERVICE_NAME }}

notify:
name: Discord Notification
Expand All @@ -134,4 +140,4 @@ jobs:
include-details: 'true'
color-success: '#1a7f37'
color-failure: '#cf222e'
color-cancelled: '#7c848d'
color-cancelled: '#7c848d'
36 changes: 21 additions & 15 deletions .github/workflows/sandbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ env:
ENVIRONMENT_NAME: sandbox
DOCKERFILE: ./Dockerfile
DOCKER_COMPOSE: .deployment/docker-compose.yaml
COMPOSE_ENV_FILE: .deployment/.env.sandbox
DOCKER_COMPOSE_DEPLOY: .deployment/compose-deploy.yaml
COMPOSE_ENV_FILE: .deployment/.env
COMPOSE_APP_ENV_FILE: .deployment/.env.compose

jobs:
dockerize:
name: Build and Push Docker image to Registry
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
environment: sandbox
steps:
-
Expand Down Expand Up @@ -69,7 +70,7 @@ jobs:
deploy:
name: Deploy Sandbox Service
runs-on: [self-hosted, linux, x64, staging, hybiot, internal]
runs-on: [self-hosted, linux, x64, ome-poc, hybiot, internal]
environment: sandbox
needs:
- dockerize
Expand Down Expand Up @@ -100,22 +101,27 @@ jobs:
-
name: Create env Docker-Compose
run: |
touch ${{ env.COMPOSE_ENV_FILE }}
echo '' > ${{ env.COMPOSE_ENV_FILE }}
echo IMAGE_NAME=ghcr.io/${{ steps.repository.outputs.lowercase }} >> ${{ env.COMPOSE_ENV_FILE }}
echo IMAGE_TAG=${{ env.sha_short }} >> ${{ env.COMPOSE_ENV_FILE }}
echo SERVICE_NAME=${{ env.SERVICE_NAME }} >> ${{ env.COMPOSE_ENV_FILE }}
touch ${{ env.COMPOSE_APP_ENV_FILE }}
cat .deployment/.env.${{ env.COMPOSE_ENV_FILE }} >> ${{ env.COMPOSE_APP_ENV_FILE }}
cat .deployment/.env.${{ env.ENVIRONMENT_NAME }} >> ${{ env.COMPOSE_APP_ENV_FILE }}
envsubst < ${{ env.DOCKER_COMPOSE }} > ${{ env.DOCKER_COMPOSE_DEPLOY }}
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 }}
-
name: Starting docker compose services
run: |
docker compose -f ${{ env.DOCKER_COMPOSE_DEPLOY }} pull
docker compose -f ${{ env.DOCKER_COMPOSE_DEPLOY }} up -d
docker ps -a
env:
COMPOSE_HTTP_TIMEOUT: 600
SERVICE_NAME: ${{ env.SERVICE_NAME }}

notify:
name: Discord Notification
Expand All @@ -135,4 +141,4 @@ jobs:
include-details: 'true'
color-success: '#1a7f37'
color-failure: '#cf222e'
color-cancelled: '#7c848d'
color-cancelled: '#7c848d'

0 comments on commit 42c4605

Please sign in to comment.