Skip to content

Commit

Permalink
Switch prod setup to Caddy
Browse files Browse the repository at this point in the history
  • Loading branch information
ngrie committed Nov 14, 2021
1 parent bb787ec commit 132a907
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 101 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/docker.yml

This file was deleted.

26 changes: 26 additions & 0 deletions docker/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 1,26 @@
{$SERVER_NAME:localhost}

log

route {
root * /var/www/public

mercure {
# Transport to use (default to Bolt)
transport_url {$MERCURE_TRANSPORT_URL:bolt://mercure.db}
# Publisher JWT key
publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG}
# Subscriber JWT key
subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG}
}

route /live {
rewrite * /live?{query}&port=1935&app=live
reverse_proxy http://rtmp
}

php_fastcgi php:9500

encode zstd gzip
file_server
}
16 changes: 11 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 7,21 @@ RUN npm install; \
npm run build


FROM nginx:alpine AS rtmpie-nginx
FROM caddy:2-builder AS caddy-builder

COPY docker/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
RUN xcaddy build \
--with github.com/dunglas/mercure \
--with github.com/dunglas/mercure/caddy


FROM caddy:2 AS rtmpie-caddy

COPY --from=caddy-builder /usr/bin/caddy /usr/bin/caddy
COPY docker/Caddyfile /etc/caddy/Caddyfile

COPY public /var/www/public
COPY --from=frontend-builder /app/public/build /var/www/public/build

WORKDIR /var/www/public


FROM php:8.0-fpm-alpine AS rtmpie-php

Expand Down Expand Up @@ -61,7 67,7 @@ ENV APP_ENV prod
ENV SYMFONY_ENV prod
ENV APP_DEBUG 0
ENV DATABASE_URL mysql://root:rtmpie@database:3306/rtmpie?serverVersion=mariadb-10.4.12
ENV MERCURE_URL http://mercure/.well-known/mercure
ENV MERCURE_URL http://caddy/.well-known/mercure
ENV RTMP_THUMBNAILS_BASE_URL http://rtmp/thumbnails/
ENV RTMP_CONTROL_MODULE_BASE_URL http://rtmp/control/
ENV RTMP_HTTP_FLV_BASE_URL /live
Expand Down
29 changes: 16 additions & 13 deletions docker/docker-compose.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 7,25 @@ services:
context: ..
dockerfile: docker/Dockerfile
target: rtmpie-php
environment:
MERCURE_PUBLIC_URL: http://127.0.0.1/.well-known/mercure

nginx:
image: docker.pkg.github.com/ngrie/rtmpie/nginx:latest
caddy:
image: docker.pkg.github.com/ngrie/rtmpie/caddy:latest
build:
context: ..
dockerfile: docker/Dockerfile
target: rtmpie-nginx
target: rtmpie-caddy
ports:
- 8080:80
- 80:80
- 443:443
environment:
SERVER_NAME: ':80'
MERCURE_PUBLISHER_JWT_KEY: '!ChangeMe!'
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeMe!'
volumes:
- mercure_data:/data
- mercure_config:/config

rtmp:
image: docker.pkg.github.com/ngrie/rtmpie/rtmp:latest
Expand All @@ -34,14 44,7 @@ services:
volumes:
- database:/var/lib/mysql

mercure:
image: dunglas/mercure:v0.9
environment:
- ALLOW_ANONYMOUS=1
- CORS_ALLOWED_ORIGINS=*
- JWT_KEY=!ChangeMe!
- PUBLISH_ALLOWED_ORIGINS=*
- USE_FORWARDED_HEADERS=1

volumes:
database:
mercure_data:
mercure_config:
8 changes: 4 additions & 4 deletions docker/nginx-rtmp/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 31,10 @@ rtmp {
live on;
record off;

on_publish http://nginx/rtmp-events/publish;
on_publish_done http://nginx/rtmp-events/publish-done;
on_play http://nginx/rtmp-events/play;
on_play_done http://nginx/rtmp-events/play-done;
on_publish http://caddy/rtmp-events/publish;
on_publish_done http://caddy/rtmp-events/publish-done;
on_play http://caddy/rtmp-events/play;
on_play_done http://caddy/rtmp-events/play-done;

exec_publish_done rm -f /tmp/thumbnail_recordings/$name.flv /var/thumbnails/$name.png;

Expand Down
53 changes: 0 additions & 53 deletions docker/nginx/conf.d/default.conf

This file was deleted.

0 comments on commit 132a907

Please sign in to comment.