Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
105 changes: 84 additions & 21 deletions .github/workflows/release-containerimage.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,111 @@
name: Create and publish a Docker image

# Configures this workflow to run every time a change is pushed to the branch called `release`.
on:
workflow_dispatch:
push:
paths-ignore:
- 'README.md'

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: TechnoTUT/rtmp-live-server
IMAGE_NAME: ghcr.io/technotut/rtmp-live-server

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
build:
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
#
strategy:
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//_}" >> $GITHUB_ENV

- name: Checkout repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry

- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
uses: docker/build-push-action@v5
images: ${{ env.IMAGE_NAME }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
platforms: ${{ matrix.platform }}
context: .
file: ./Containerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: Containerfile
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"

- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-24.04
needs: build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.IMAGE_NAME }}@sha256:%s ' *)

- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
27 changes: 21 additions & 6 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
FROM alqutami/rtmp-hls:latest
FROM debian:13-slim

LABEL maintainer="TechnoTUT <gh@technotut.net>"

EXPOSE 1935
EXPOSE 80

ENV DEBIAN_FRONTEND noninteractive

Check warning on line 8 in Containerfile

View workflow job for this annotation

GitHub Actions / build (linux/amd64)

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

Check warning on line 8 in Containerfile

View workflow job for this annotation

GitHub Actions / build (linux/arm64)

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

RUN apt-get update -y && apt-get upgrade -y \
&& apt-get install -y nginx libnginx-mod-rtmp \
&& rm -rf /var/lib/apt/lists/* \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log \
&& rm -rf /etc/nginx/nginx.conf \
&& rm -rf /var/www/html/favicon.ico \
&& mkdir -p /var/www/html/rtmp

RUN rm -rf /etc/nginx/nginx.conf && \
rm -rf /usr/local/nginx/html/players && \
rm -rf /usr/local/nginx/html/favicon.ico
COPY nginx.conf /etc/nginx/nginx.conf
COPY players /usr/local/nginx/html/players
COPY favicon.ico /usr/local/nginx/html/favicon.ico
COPY favicon.ico /var/www/html/favicon.ico
COPY stat.xsl /var/www/html/rtmp/stat.xsl

CMD ["nginx", "-g", "daemon off;"]
39 changes: 5 additions & 34 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load_module /usr/lib/nginx/modules/ngx_rtmp_module.so;

worker_processes auto;
#error_log logs/error.log;

Expand All @@ -10,17 +12,11 @@ rtmp {
server {
listen 1935; # Listen on standard RTMP port
listen [::]:1935 ipv6only=on;
chunk_size 4000;
chunk_size 4096;

application live {
live on;
drop_idle_publisher 10s;

hls on;
hls_fragment 3;
hls_playlist_length 20;
hls_path /mnt/hls/;
hls_variant _mid BANDWIDTH=448000;
record off; # Disable recording
}
}
}
Expand All @@ -35,31 +31,6 @@ http {
listen 8080;
listen [::]:8080 ipv6only=on;

# Serve HLS fragments
location /hls {
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}

root /mnt;

add_header Cache-Control no-cache; # Disable cache

# CORS setup
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length';

# allow CORS preflight requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
}

# This URL provides RTMP statistics in XML
location /stat {
rtmp_stat all;
Expand All @@ -68,7 +39,7 @@ http {

location /stat.xsl {
# XML stylesheet to view RTMP stats.
root /usr/local/nginx/html;
root /var/www/html/rtmp;
}

}
Expand Down
22 changes: 0 additions & 22 deletions players/hls.html

This file was deleted.

38 changes: 0 additions & 38 deletions players/hls_hlsjs.html

This file was deleted.

23 changes: 0 additions & 23 deletions players/rtmp.html

This file was deleted.

26 changes: 0 additions & 26 deletions players/rtmp_hls.html

This file was deleted.

Loading
Loading