diff --git a/Cargo.toml b/Cargo.toml index 7547c893..58c4a0c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ members = [ "crates/services/*", "crates/daemons/*", ] +exclude = ["crates/services/assets"] [patch.crates-io] redis23 = { package = "redis", version = "0.23.3", git = "https://github.com/revoltchat/redis-rs", rev = "523b2937367e17bd0073722bf6e23d06042cb4e4" } diff --git a/compose.yml b/compose.yml index b7e73689..f9789957 100644 --- a/compose.yml +++ b/compose.yml @@ -86,3 +86,11 @@ services: network_mode: "host" volumes: - ./livekit.yml:/etc/livekit.yml + + assets: + build: ./crates/services/assets + ports: + - "14707:14707" + volumes: + - ./assets-custom:/srv/assets/custom + restart: unless-stopped \ No newline at end of file diff --git a/crates/services/assets/Caddyfile b/crates/services/assets/Caddyfile new file mode 100644 index 00000000..a5c1c156 --- /dev/null +++ b/crates/services/assets/Caddyfile @@ -0,0 +1,35 @@ +{ + admin off + auto_https off +} + +:14707 { + encode gzip zstd + + route { + header Access-Control-Allow-Origin * + header Cache-Control "public, max-age=86400" + + respond /health 200 + + # Serve from custom/ first if the file exists there, so + # self-hosters can add new assets or override shipped ones + # just by dropping a file at the same relative path. + @custom { + file { + root /srv/assets/custom + try_files {http.request.uri.path} + } + } + handle @custom { + root * /srv/assets/custom + file_server + } + + # Fall back to the assets baked into the image. + handle { + root * /srv/assets/default + file_server + } + } +} diff --git a/crates/services/assets/Dockerfile b/crates/services/assets/Dockerfile new file mode 100644 index 00000000..eedfd15a --- /dev/null +++ b/crates/services/assets/Dockerfile @@ -0,0 +1,15 @@ +FROM caddy:2-alpine + +# Baked-in default assets, shipped inside the image. +COPY default /srv/assets/default + +# Self-hosters override this path with a volume mount to add or replace +# assets without rebuilding the image +COPY custom /srv/assets/custom + +COPY Caddyfile /etc/caddy/Caddyfile + +EXPOSE 14707 + +HEALTHCHECK --interval=30s --timeout=3s \ + CMD wget -qO- http://localhost:14707/health || exit 1 \ No newline at end of file