diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cd9c59b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +_build/ +.git/ +.github/ +CMakeCache.txt +CMakeFiles/ +Testing/ +*.o +*.a +*.so \ No newline at end of file diff --git a/.github/workflows/docker-build-amd64.yml b/.github/workflows/docker-build-amd64.yml new file mode 100644 index 0000000..c6ce398 --- /dev/null +++ b/.github/workflows/docker-build-amd64.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/docker-build-arm64.yml b/.github/workflows/docker-build-arm64.yml new file mode 100644 index 0000000..0c53826 --- /dev/null +++ b/.github/workflows/docker-build-arm64.yml @@ -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 \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..ea3bd51 --- /dev/null +++ b/docker/Dockerfile @@ -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}"] \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..14b5d23 --- /dev/null +++ b/docker/docker-compose.yml @@ -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} + \ No newline at end of file