feat: add docker-compose.yml
This commit is contained in:
parent
75e7dc03bf
commit
8e4f0a6844
32
Dockerfile
32
Dockerfile
|
@ -1,8 +1,8 @@
|
||||||
FROM rust:latest as builder
|
FROM rust:bookworm as builder
|
||||||
|
|
||||||
# Create a build directory and copy over all of the files
|
# Create a build directory and copy over all of the files
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
COPY . .
|
COPY . ./
|
||||||
|
|
||||||
# Reuse a cache between builds.
|
# Reuse a cache between builds.
|
||||||
# I tried to `cargo install`, but it doesn't seem to work with workspaces.
|
# I tried to `cargo install`, but it doesn't seem to work with workspaces.
|
||||||
|
@ -12,28 +12,20 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||||
--mount=type=cache,target=/build/target \
|
--mount=type=cache,target=/build/target \
|
||||||
cargo build --release && cp /build/target/release/moq-* /usr/local/cargo/bin
|
cargo build --release && cp /build/target/release/moq-* /usr/local/cargo/bin
|
||||||
|
|
||||||
# Special image for moq-pub with ffmpeg and a publish script included.
|
# moq-rs image with just the binaries
|
||||||
FROM rust:latest as moq-pub
|
FROM debian:bookworm-slim
|
||||||
|
|
||||||
# Install required utilities and ffmpeg
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y ffmpeg wget
|
apt-get install -y --no-install-recommends curl libssl3 && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
# Copy the publish script into the image
|
|
||||||
COPY deploy/publish.sh /usr/local/bin/publish
|
|
||||||
|
|
||||||
# Copy the compiled binaries
|
|
||||||
COPY --from=builder /usr/local/cargo/bin /usr/local/cargo/bin
|
|
||||||
CMD [ "publish" ]
|
|
||||||
|
|
||||||
# moq-rs image with just the binaries (default)
|
|
||||||
FROM rust:latest as moq-rs
|
|
||||||
|
|
||||||
LABEL org.opencontainers.image.source=https://github.com/kixelated/moq-rs
|
LABEL org.opencontainers.image.source=https://github.com/kixelated/moq-rs
|
||||||
LABEL org.opencontainers.image.licenses="MIT OR Apache-2.0"
|
LABEL org.opencontainers.image.licenses="MIT OR Apache-2.0"
|
||||||
|
|
||||||
# Fly.io entrypoint
|
COPY --from=builder /usr/local/cargo/bin /usr/local/bin
|
||||||
ADD deploy/fly-relay.sh .
|
|
||||||
|
|
||||||
# Copy the compiled binaries
|
# Entrypoint to load relay TLS config in Fly:
|
||||||
COPY --from=builder /usr/local/cargo/bin /usr/local/cargo/bin
|
COPY deploy/fly-relay.sh .
|
||||||
|
|
||||||
|
# Default to moq-relay:
|
||||||
|
CMD ["moq-relay"]
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
export CAROOT ?= $(shell cd dev ; go run filippo.io/mkcert -CAROOT)
|
||||||
|
|
||||||
|
.PHONY: run
|
||||||
|
run: dev/localhost.crt
|
||||||
|
@docker-compose up --build --remove-orphans
|
||||||
|
|
||||||
|
dev/localhost.crt:
|
||||||
|
@dev/cert
|
12
README.md
12
README.md
|
@ -17,7 +17,17 @@ There's currently no way to view media with this repo; you'll need to use [moq-j
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
Use the [dev helper scripts](dev/README.md) for local development.
|
Launch backend containers (including two relays, API and a Redis instance) using docker-compose:
|
||||||
|
|
||||||
|
```
|
||||||
|
make run
|
||||||
|
```
|
||||||
|
|
||||||
|
As well as launching the containers, this handles the creation and transfer of TLS certificates.
|
||||||
|
|
||||||
|
Then, visit https://quic.video/publish/?server=localhost:4443.
|
||||||
|
|
||||||
|
Alternatively, use the [dev helper scripts](dev/README.md).
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
# Local Development
|
# Local Development
|
||||||
|
|
||||||
This is a collection of helpful scripts for local development.
|
## Quickstart with Docker
|
||||||
|
|
||||||
## Setup
|
Launch a basic cluster, including provisioning certs and deploying root certificates:
|
||||||
|
|
||||||
|
```
|
||||||
|
# From repo root:
|
||||||
|
make run
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Manual setup
|
||||||
|
|
||||||
|
This is a collection of helpful scripts for local development.
|
||||||
|
|
||||||
### moq-relay
|
### moq-relay
|
||||||
|
|
||||||
|
|
2
dev/cert
2
dev/cert
|
@ -15,4 +15,4 @@ go run filippo.io/mkcert -ecdsa -install
|
||||||
# Generate a new certificate for localhost
|
# Generate a new certificate for localhost
|
||||||
# This fork of mkcert supports the -days flag.
|
# This fork of mkcert supports the -days flag.
|
||||||
# TODO remove the -days flag when Chrome accepts self-signed certs.
|
# TODO remove the -days flag when Chrome accepts self-signed certs.
|
||||||
go run filippo.io/mkcert -ecdsa -days 10 -cert-file "$CRT" -key-file "$KEY" localhost 127.0.0.1 ::1
|
go run filippo.io/mkcert -ecdsa -days 10 -cert-file "$CRT" -key-file "$KEY" localhost 127.0.0.1 ::1 relay1 relay2
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
x-relay: &x-relay
|
||||||
|
build: .
|
||||||
|
entrypoint: ["moq-relay"]
|
||||||
|
environment:
|
||||||
|
RUST_LOG: ${RUST_LOG:-debug}
|
||||||
|
volumes:
|
||||||
|
- ./dev/localhost.crt:/etc/tls/cert:ro
|
||||||
|
- ./dev/localhost.key:/etc/tls/key:ro
|
||||||
|
- certs:/etc/ssl/certs
|
||||||
|
depends_on:
|
||||||
|
install-certs:
|
||||||
|
condition: service_completed_successfully
|
||||||
|
|
||||||
|
services:
|
||||||
|
redis:
|
||||||
|
image: redis:7
|
||||||
|
ports:
|
||||||
|
- "6400:6379"
|
||||||
|
|
||||||
|
api:
|
||||||
|
build: .
|
||||||
|
entrypoint: moq-api
|
||||||
|
command: --listen [::]:4442 --redis redis://redis:6379
|
||||||
|
|
||||||
|
relay1:
|
||||||
|
<<: *x-relay
|
||||||
|
command: --listen [::]:4443 --tls-cert /etc/tls/cert --tls-key /etc/tls/key --api http://api:4442 --api-node https://relay1:4443 --dev
|
||||||
|
ports:
|
||||||
|
- "4443:4443"
|
||||||
|
- "4443:4443/udp"
|
||||||
|
|
||||||
|
relay2:
|
||||||
|
<<: *x-relay
|
||||||
|
command: --listen [::]:4443 --tls-cert /etc/tls/cert --tls-key /etc/tls/key --api http://api:4442 --api-node https://relay2:4443 --dev
|
||||||
|
ports:
|
||||||
|
- "4444:4443"
|
||||||
|
- "4444:4443/udp"
|
||||||
|
|
||||||
|
install-certs:
|
||||||
|
image: golang:latest
|
||||||
|
working_dir: /work
|
||||||
|
command: go run filippo.io/mkcert -install
|
||||||
|
environment:
|
||||||
|
CAROOT: /work/caroot
|
||||||
|
volumes:
|
||||||
|
- ${CAROOT:-.}:/work/caroot
|
||||||
|
- certs:/etc/ssl/certs
|
||||||
|
- ./dev/go.mod:/work/go.mod:ro
|
||||||
|
- ./dev/go.sum:/work/go.sum:ro
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
certs:
|
Loading…
Reference in New Issue