refactor docker build

This commit is contained in:
Roy Olav Purser 2021-05-21 10:58:13 +02:00
parent 091ec59265
commit b4d7b81a66
Signed by: roypur
GPG Key ID: E14D26A036F21656
4 changed files with 30 additions and 27 deletions

View File

@ -1,9 +1,7 @@
FROM alpine:edge as base FROM roypur/stream-runtime:latest as base
RUN ["apk", "add", "--no-cache", "py3-virtualenv"]
RUN ["mkdir", "-p", "/app/version"] RUN ["mkdir", "-p", "/app/version"]
COPY ["tv.json", "/app/setup/tv.json"] COPY ["tv.json", "/app/setup/tv.json"]
COPY ["backend/start.sh", "/app/start.sh"] COPY ["backend/start.sh", "/app/start.sh"]
COPY ["backend/install.sh", "/app/setup/install.sh"]
COPY ["backend/sources.py", "/app/setup/sources.py"] COPY ["backend/sources.py", "/app/setup/sources.py"]
COPY ["backend/stream.py", "/app/stream.py"] COPY ["backend/stream.py", "/app/stream.py"]
COPY ["backend/stream_providers.py", "/app/stream_providers.py"] COPY ["backend/stream_providers.py", "/app/stream_providers.py"]
@ -11,20 +9,11 @@ COPY ["frontend/index.html", "/app/index.html"]
COPY ["frontend/script.js", "/app/script.js"] COPY ["frontend/script.js", "/app/script.js"]
COPY ["frontend/style.css", "/app/style.css"] COPY ["frontend/style.css", "/app/style.css"]
RUN ["chmod", "-R", "755", "/app"] RUN ["chmod", "-R", "755", "/app"]
RUN ["/app/venv/bin/python3", "/app/setup/sources.py"]
FROM base as sources
RUN ["apk", "add", "--no-cache", "py3-requests"]
RUN ["python3", "/app/setup/sources.py"]
RUN ["rm", "-r", "/app/setup"]
FROM base as venv
RUN ["apk", "add", "--no-cache", "musl-dev", "build-base", "python3-dev"]
RUN ["/app/setup/install.sh"]
RUN ["rm", "-r", "/app/setup"] RUN ["rm", "-r", "/app/setup"]
FROM scratch FROM scratch
COPY --from=sources / / COPY --from=base / /
COPY --from=venv /app/venv /app/venv
USER 1444:1444 USER 1444:1444
ENV ICECAST_SERVER=https://icecast.purser.it:7000 ENV ICECAST_SERVER=https://icecast.purser.it:7000
ENV STREAM_SERVER=https://stream.purser.it ENV STREAM_SERVER=https://stream.purser.it

View File

@ -2,14 +2,13 @@
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1">{% for item in meta %} <meta name="viewport" content="width=device-width, initial-scale=1">{% for item in meta %}
{% block item %}<meta property="{{ item[0] }}" content="{{ item[1] }}" />{% end %}{% end %} {% block item %}<meta property="{{ item[0] }}" content="{{ item[1] }}" />{% end %}{% end %}
<script async src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js"></script>
<script async src="https://www.gstatic.com/cast/sdk/libs/sender/1.0/cast_framework.js"></script>
<script async src="{{ data["script"] }}"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/video.js/{{ data["videojs_version"] }}/video.min.js"></script> <script defer src="https://cdnjs.cloudflare.com/ajax/libs/video.js/{{ data["videojs_version"] }}/video.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/@silvermine/videojs-chromecast@{{ data["chromecast_version"] }}/dist/silvermine-videojs-chromecast.min.js"></script> <script defer src="https://cdn.jsdelivr.net/npm/@silvermine/videojs-chromecast@{{ data["chromecast_version"] }}/dist/silvermine-videojs-chromecast.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/{{ data["font_awesome_version"] }}/css/all.min.css"> <script defer src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js"></script>
<script defer src="https://www.gstatic.com/cast/sdk/libs/sender/1.0/cast_framework.js"></script>
<script defer src="{{ data["script"] }}"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/video.js/{{ data["videojs_version"] }}/video-js.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/video.js/{{ data["videojs_version"] }}/video-js.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@silvermine/videojs-chromecast@{{ data["chromecast_version"] }}/dist/silvermine-videojs-chromecast.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/{{ data["font_awesome_version"] }}/css/all.min.css">
<link rel="stylesheet" href="{{ data["custom_style"] }}"> <link rel="stylesheet" href="{{ data["custom_style"] }}">
</head> </head>
<body> <body>

View File

@ -35,6 +35,7 @@
options.techOrder = ["chromecast", "html5"]; options.techOrder = ["chromecast", "html5"];
options.plugins = {}; options.plugins = {};
options.plugins.chromecast = {}; options.plugins.chromecast = {};
options.plugins.chromecast.addButtonToControlBar = false;
const player = videojs(video, options); const player = videojs(video, options);
const source = {}; const source = {};
source.type = ctype; source.type = ctype;
@ -45,18 +46,29 @@
cbutton.clickHandler = (ev) => { cbutton.clickHandler = (ev) => {
player.trigger("chromecastRequested"); player.trigger("chromecastRequested");
} }
const button = new Button(player, cbutton); cbutton.text = "Chromecast";
button.addClass("fab");
button.addClass("fa-chromecast"); const bigCastButton = new Button(player, cbutton);
button.addClass("vjs-control"); bigCastButton.addClass("fab");
button.addClass("vjs-button"); bigCastButton.addClass("fa-chromecast");
button.addClass("vjs-big-chromecast"); bigCastButton.addClass("vjs-control");
bigCastButton.addClass("vjs-button");
bigCastButton.addClass("vjs-big-chromecast");
player.addChild(bigCastButton);
const smallCastButton = new Button(player, cbutton);
smallCastButton.addClass("fab");
smallCastButton.addClass("fa-chromecast");
smallCastButton.addClass("vjs-control");
smallCastButton.addClass("vjs-button");
player.controlBar.addChild(smallCastButton);
player.addChild(button);
player.one("play", () => { player.one("play", () => {
player.removeChild(button); player.removeChild(bigCastButton);
}); });
player.on("chromecastConnected", () => { player.on("chromecastConnected", () => {
console.log(player.chromecastSessionManager.remotePlayer.volumeLevel);
if(player.volume() > 0.3) { if(player.volume() > 0.3) {
player.volume(0.2); player.volume(0.2);
} }

View File

@ -1,6 +1,9 @@
body { body {
margin: 0px; margin: 0px;
} }
.fa-chromecast:before {
font-size: 1.2em;
}
.vjs-big-chromecast { .vjs-big-chromecast {
position: absolute !important; position: absolute !important;
font-size: 3rem !important; font-size: 3rem !important;