Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker support #7

Closed
wants to merge 13 commits into from
Closed
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
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
_build/
.git/
.github/
CMakeCache.txt
CMakeFiles/
Testing/
*.o
*.a
*.so
39 changes: 39 additions & 0 deletions .github/workflows/docker-build-amd64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Docker Build AMD64
on:
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/moqrelay

jobs:
build-amd64:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to registry
if: github.event_name != 'pull_request'
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build amd64 image
run: |
docker build . -f docker/Dockerfile \
-t ghcr.io/${{ env.IMAGE_NAME }}:latest-amd64 \
-t ghcr.io/${{ env.IMAGE_NAME }}:${{ github.sha }}-amd64

- name: Push amd64 image
if: github.event_name != 'pull_request'
run: |
docker push ghcr.io/${{ env.IMAGE_NAME }}:latest-amd64
docker push ghcr.io/${{ env.IMAGE_NAME }}:${{ github.sha }}-amd64
41 changes: 41 additions & 0 deletions .github/workflows/docker-build-arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Docker Build ARM64
on:
push:
tags:
- 'v*'
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/moqrelay

jobs:
build-arm64:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Log in to registry
if: github.event_name != 'pull_request'
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Build arm64 image
run: |
docker build . -f docker/Dockerfile \
--platform linux/arm64 \
-t ghcr.io/${{ env.IMAGE_NAME }}:latest-arm64 \
-t ghcr.io/${{ env.IMAGE_NAME }}:${{ github.sha }}-arm64

- name: Push arm64 image
if: github.event_name != 'pull_request'
run: |
docker push ghcr.io/${{ env.IMAGE_NAME }}:latest-arm64
docker push ghcr.io/${{ env.IMAGE_NAME }}:${{ github.sha }}-arm64
63 changes: 63 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Dockerfile for building the Moq Relay Server
#
# docker build -t moqrelay -f docker/Dockerfile .
#
# To run the container:
#
# Using default values (udp port 4433, logging DBG)
# docker run --rm -p 4433:4433/udp moqrelay
#
# Override logging level
# docker run --rm -p 4433:4433/udp -e MOQ_LOG_LEVEL=INFO moqrelay
#
# Override both port and logging
# docker run --rm -p 8080:8080/udp -e MOQ_PORT=8080 -e MOQ_LOG_LEVEL=INFO moqrelay
#
# Using certs from a specific host directory
# docker run --rm -p 4433:4433/udp \
# -v /path/to/your/certs:/certs \
# moqrelay
#
# Using individual cert files with different names
# docker run --rm -p 4433:4433/udp \
# -v /path/to/custom.pem:/certs/certificate.pem \
# -v /path/to/custom.key:/certs/certificate.key \
# moqrelay
#
# # Using completely custom paths with environment variables
# docker run --rm -p 4433:4433/udp \
# -v /path/to/certs:/custom/certs \
# -e CERT_FILE=/custom/certs/my-cert.pem \
# -e KEY_FILE=/custom/certs/my-key.key \
# moqrelay
#
FROM ubuntu:latest

# Install essential build tools and dependencies
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
gcc \
g++ \
make \
doxygen \
&& rm -rf /var/lib/apt/lists/*

# Set up working directory
WORKDIR /app

# Copy the rest of the project files
COPY . .

# Run the build script (already running as root)
RUN ./build.sh
RUN ./scripts/create-server-certs.sh

# Set default environment variables
ENV MOQ_LOG_LEVEL=DBG
ENV MOQ_PORT=4433

EXPOSE ${MOQ_PORT}/udp

CMD ["sh", "-c", "./_build/bin/moqrelayserver -port ${MOQ_PORT} -cert ./certs/certificate.pem -key ./certs/certificate.key -endpoint \"/moq\" --logging ${MOQ_LOG_LEVEL}"]
17 changes: 17 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3.8'

services:
moqrelay:
build:
context: .
dockerfile: docker/Dockerfile
ports:
- "${MOQ_PORT}:${MOQ_PORT}"
volumes:
- ${CERT_PATH:-./certs}:/certs
environment:
- MOQ_LOG_LEVEL=${MOQ_LOG_LEVEL:-DBG}
- MOQ_PORT=${MOQ_PORT:-4433}
- CERT_FILE=${CERT_FILE:-/certs/certificate.pem}
- KEY_FILE=${KEY_FILE:-/certs/certificate.key}

Loading