add Dockerfile and docker-compose for multi-stage build; update .gitignore and various HTML examples

This commit is contained in:
Elmar Kresse
2025-12-28 15:50:59 +01:00
parent 49a1ef45da
commit 0d376597d6
10 changed files with 189 additions and 23 deletions

3
.gitignore vendored
View File

@@ -5,4 +5,5 @@
*.mp4
*.png
/pb_data/storage/
/pb_data/storage/**
/pb_data/storage/**
*.DS_Store

24
Dockerfile Normal file
View File

@@ -0,0 +1,24 @@
# Multi-stage Dockerfile for Go (PocketBase) project
# --- Build Stage ---
FROM golang:1.21-alpine AS builder
WORKDIR /app
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o server main.go
# --- Development Stage ---
FROM golang:1.21-alpine AS dev
WORKDIR /app
COPY --from=builder /app /app
EXPOSE 8080
CMD ["go", "run", "main.go"]
# --- Production Stage ---
FROM alpine:3.18 AS prod
WORKDIR /app
COPY --from=builder /app/server /app/server
COPY pb_public /app/pb_public
EXPOSE 8080
CMD ["/app/server"]

20
docker-compose.yml Normal file
View File

@@ -0,0 +1,20 @@
services:
app-prod:
build:
context: .
dockerfile: Dockerfile
target: prod
image: dbr-app:latest
ports:
- "8080:8080"
restart: unless-stopped
environment:
- POCKETBASE_HTTP_ADDR=0.0.0.0:8080
volumes:
- ./pb_public:/app/pb_public:ro
- ./pb_data:/app/pb_data
command: ["/app/server", "serve", "--http=0.0.0.0:8080"]
volumes:
pb_public: {}
pb_data: {}

View File

@@ -50,7 +50,8 @@
// Check if HLS.js is supported
if (Hls.isSupported()) {
const hls = new Hls();
const proxyUrl = 'http://127.0.0.1:8090/cors?url=https://brevent.akamaized.net/hls/live/2028222/event_05/master1080p5000.m3u8';
const localwindowurl = window.location.origin;
const proxyUrl = localwindowurl + '/cors?url=https://brevent.akamaized.net/hls/live/2028222/event_05/master1080p5000.m3u8';
hls.loadSource(proxyUrl);
hls.attachMedia(videoPlayer);
} else {

View File

@@ -35,25 +35,11 @@
<body>
<div id="video-container">
<video id="videoPlayer" controls autoplay playsinline muted></video>
<button id="fullscreen-button">Fullscreen</button>
</div>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script>
const videoPlayer = document.getElementById('videoPlayer');
const fullscreenButton = document.getElementById('fullscreen-button');
fullscreenButton.addEventListener('click', () => {
if (videoPlayer.requestFullscreen) {
videoPlayer.requestFullscreen();
} else if (videoPlayer.mozRequestFullScreen) { /* Firefox */
videoPlayer.mozRequestFullScreen();
} else if (videoPlayer.webkitRequestFullscreen) { /* Chrome, Safari & Opera */
videoPlayer.webkitRequestFullscreen();
} else if (videoPlayer.msRequestFullscreen) { /* IE/Edge */
videoPlayer.msRequestFullscreen();
}
});
// Add event listener when video ends to loop it
videoPlayer.addEventListener('ended', function() {
@@ -64,11 +50,12 @@
// Check if HLS.js is supported
if (Hls.isSupported()) {
const hls = new Hls();
hls.loadSource('https://ch-fra-n16.livespotting.com/vpu/qjkdtjva/4ctm3g1a_720.m3u8');
const proxyUrl = 'https://ch-fra-n16.livespotting.com/vpu/qjkdtjva/4ctm3g1a_720.m3u8';
hls.loadSource(proxyUrl);
hls.attachMedia(videoPlayer);
} else {
console.error('HLS not supported');
}
</script>
</body>
</html>
</html>

View File

@@ -20,7 +20,7 @@
</style>
</head>
<body>
<iframe src="https://webtv.feratel.com/webtv/?cam=3175&design=v4&pg=5EB12424-7C2D-428A-BEFF-0C9140CD772F" id="embedded-frame"></iframe>
<iframe src="https://webtv.feratel.com/webtv/?design=v4&pg=5EB12424-7C2D-428A-BEFF-0C9140CD772F&cam=3175" id="embedded-frame"></iframe>
<script>
const iframe = document.getElementById('embedded-frame');

View File

@@ -19,7 +19,7 @@
</style>
</head>
<body>
<iframe src="https://radar.wo-cloud.com/desktop/rr/interactive?wry=51.83,10.78&wrn=V2VybmlnZXJvZGU%3D&wrg=10454&wrf=true&wrx=51.83,10.78&wro=true&wrm=8" id="embedded-frame"></iframe>
<iframe src="https://radar.wo-cloud.com/desktop/wr/interactive?wry=51.83,10.78&wrn=V2VybmlnZXJvZGU%3D&wrg=10454&wrf=false&wrx=51.83,10.78&wro=true&wrm=9" id="embedded-frame"></iframe>
<script>
const iframe = document.getElementById('embedded-frame');

6
go.mod
View File

@@ -2,7 +2,10 @@ module dbr-backend
go 1.19
require github.com/pocketbase/pocketbase v0.12.1-0.20230130105451-250642a8f97f
require (
github.com/labstack/echo/v5 v5.0.0-20220201181537-ed2888cfa198
github.com/pocketbase/pocketbase v0.12.1-0.20230130105451-250642a8f97f
)
require (
github.com/AlecAivazis/survey/v2 v2.3.6 // indirect
@@ -43,7 +46,6 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/labstack/echo/v5 v5.0.0-20220201181537-ed2888cfa198 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-sqlite3 v1.14.16 // indirect

View File

@@ -48,7 +48,7 @@
const sliderArrayQuery = [];
const pb = new PocketBase('http://192.168.178.57:8090');
const pb = new PocketBase('http://127.0.0.1:8080');
const media = pb.collection('media').getFullList(2000, {
sort: '-created',

131
pb_schema.json Normal file
View File

@@ -0,0 +1,131 @@
[
{
"id": "_pb_users_auth_",
"name": "users",
"type": "auth",
"system": false,
"schema": [
{
"id": "users_name",
"name": "name",
"type": "text",
"system": false,
"required": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"id": "users_avatar",
"name": "avatar",
"type": "file",
"system": false,
"required": false,
"unique": false,
"options": {
"maxSelect": 1,
"maxSize": 5242880,
"mimeTypes": [
"image/jpeg",
"image/png",
"image/svg+xml",
"image/gif",
"image/webp"
],
"thumbs": null
}
}
],
"listRule": "id = @request.auth.id",
"viewRule": "id = @request.auth.id",
"createRule": "",
"updateRule": "id = @request.auth.id",
"deleteRule": "id = @request.auth.id",
"options": {
"allowEmailAuth": true,
"allowOAuth2Auth": true,
"allowUsernameAuth": true,
"exceptEmailDomains": null,
"manageRule": null,
"minPasswordLength": 8,
"onlyEmailDomains": null,
"requireEmail": false
}
},
{
"id": "pgdcj2dyt12pena",
"name": "media",
"type": "base",
"system": false,
"schema": [
{
"id": "dy3k4o8r",
"name": "media",
"type": "file",
"system": false,
"required": false,
"unique": false,
"options": {
"maxSelect": 1,
"maxSize": 52428800,
"mimeTypes": [
"image/jpeg",
"video/x-matroska",
"image/png",
"image/vnd.mozilla.apng",
"audio/mp4",
"video/mp4",
"text/html",
"image/avif",
"video/x-msvideo",
"image/gif"
],
"thumbs": []
}
},
{
"id": "qqbokwdk",
"name": "group",
"type": "text",
"system": false,
"required": false,
"unique": false,
"options": {
"min": 3,
"max": 64,
"pattern": ""
}
},
{
"id": "sm5nbveu",
"name": "duration",
"type": "number",
"system": false,
"required": false,
"unique": false,
"options": {
"min": 1,
"max": 100000000
}
},
{
"id": "g75s2yuu",
"name": "enabled",
"type": "bool",
"system": false,
"required": false,
"unique": false,
"options": {}
}
],
"listRule": "",
"viewRule": "",
"createRule": "",
"updateRule": "",
"deleteRule": "",
"options": {}
}
]