Compare commits

...

3 Commits

Author SHA1 Message Date
445f522fa8 Refactor code structure for improved readability and maintainability 2025-10-19 22:08:17 +02:00
bec0a3b72f Merge remote-tracking branch 'origin/main' into deno-rewrite 2025-10-19 22:00:50 +02:00
Elmar Kresse
d17c78fa68 fix: correct year and date for multiple songs in years.json
All checks were successful
Build and Push Docker Image / docker (push) Successful in 7s
2025-10-19 18:25:20 +02:00
12 changed files with 2259 additions and 2199 deletions

View File

@@ -11,4 +11,11 @@ data/*
*.wav
*.m4a
*.ogg
*.flac
*.flac
**/data/*.mp3
**/data/*.wav
**/data/*.m4a
**/data/*.opus
**/data/*.ogg
**/data/*.flac

View File

@@ -165,6 +165,7 @@ jobs:
echo "Building $IMAGE_FULL with tags: $TAG_ARGS"
docker buildx build \
--platform linux/amd64 \
--target production \
-f "$DOCKERFILE" \
$TAG_ARGS \
--cache-from type=registry,ref="$IMAGE_FULL:buildcache" \

View File

@@ -1,23 +1,52 @@
# Lightweight production image for the Hitstar Node app
FROM node:22-alpine
# Multi-stage Dockerfile for Hitstar Deno Server
# Supports both development and production environments
# Base stage with common dependencies
FROM denoland/deno:latest AS base
WORKDIR /app
# Install dependencies
COPY package*.json ./
# Use npm ci when a lockfile is present, otherwise fallback to npm install without throwing an error
RUN if [ -f package-lock.json ] || [ -f npm-shrinkwrap.json ]; then \
npm ci --omit=dev; \
else \
npm install --omit=dev; \
fi
# Copy all source files first for dependency resolution
COPY src/server-deno/ .
# Copy app source (media lives outside via volume)
COPY . .
# Cache all dependencies based on deno.json imports
RUN deno cache main.ts
ENV NODE_ENV=production \
# Development stage
FROM base AS development
ENV DENO_ENV=development \
PORT=5173
EXPOSE 5173
CMD ["node", "src/server/index.js", "--host", "0.0.0.0"]
# Copy all source files
COPY src/server-deno/ .
# Run with watch mode and all necessary permissions
CMD ["deno", "run", \
"--allow-net", \
"--allow-read", \
"--allow-env", \
"--allow-write", \
"--watch", \
"main.ts"]
# Production stage
FROM base AS production
ENV DENO_ENV=production \
PORT=5173
EXPOSE 5173
# Copy only necessary source files for production
COPY src/server-deno/ .
# Run optimized production server
CMD ["deno", "run", \
"--allow-net", \
"--allow-read=/app/data,/app/public", \
"--allow-env", \
"--allow-write=/app/data", \
"main.ts"]

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,24 @@
services:
# Production service
hitstar:
build: .
image: hitstar-webapp:latest
build:
context: .
dockerfile: Dockerfile
target: production
image: hitstar-deno:prod
container_name: hitstar
environment:
- NODE_ENV=production
- DENO_ENV=production
- PORT=5173
ports:
- "5173:5173"
volumes:
- ./data:/app/data:rw
restart: unless-stopped
- ./data:/app/data:ro
- ./src/server-deno/public:/app/public:ro
restart: unless-stopped
networks:
- hitstar-network
networks:
hitstar-network:
driver: bridge

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 KiB

View File

@@ -122,8 +122,8 @@
"mbid": null
},
"Bill Haley & His Comets - (We're Gonna) Rock Around The Clock (Single Version).opus": {
"year": 2014,
"date": "2014-09-19",
"year": 1955,
"date": "1955",
"title": "(We're Gonna) Rock Around The Clock (Single Version)",
"artist": "Bill Haley & His Comets",
"mbid": "5e17cc2d-368d-4abb-b22c-71b08d6cfef9"
@@ -136,8 +136,8 @@
"mbid": "732b4543-1820-4cb6-b7cb-25c0356f1f5b"
},
"Bill Medley - (I've Had) The Time Of My Life (From Dirty Dancing Soundtrack).opus": {
"year": 2024,
"date": "2024",
"year": 1987,
"date": "1987",
"title": "(I've Had) The Time Of My Life (From \"Dirty Dancing\" Soundtrack)",
"artist": "Bill Medley, Jennifer Warnes",
"mbid": "3da1ab83-49aa-4b69-a6e9-9566f3c3f5fa"
@@ -444,8 +444,8 @@
"mbid": "c3c3b281-5943-4c7d-bd1c-69d877277714"
},
"Danny and The Juniors - At The Hop.opus": {
"year": 1986,
"date": "1986",
"year": 1957,
"date": "1957",
"title": "At The Hop",
"artist": "Danny and The Juniors",
"mbid": "8e980a28-f25b-495e-94be-b19b56f6019c"
@@ -816,7 +816,7 @@
},
"Haddaway - What Is Love (7 Mix).opus": {
"year": 1993,
"date": "1993-01-18",
"date": "1993",
"title": "What Is Love (7\" Mix)",
"artist": "Haddaway",
"mbid": "2970d12e-5eb9-45c9-8eac-38ce11efc18f"
@@ -1123,8 +1123,8 @@
"mbid": "a393ce94-3cbc-4723-97de-7a270bb7b606"
},
"Little Eva - The Locomotion.opus": {
"year": 1992,
"date": "1992",
"year": 1962,
"date": "1962",
"title": "The Locomotion",
"artist": "Little Eva",
"mbid": "77077947-1945-421a-bdb7-fd057a9ec546"
@@ -1151,8 +1151,8 @@
"mbid": "87e36ab4-6914-44ab-b740-7abb37678040"
},
"Lynyrd Skynyrd - Sweet Home Alabama.opus": {
"year": 1976,
"date": "1976-09",
"year": 1974,
"date": "1974",
"title": "Sweet Home Alabama",
"artist": "Lynyrd Skynyrd",
"mbid": "8392991c-3929-4bf9-a8fb-461bb9aca76d"
@@ -1627,8 +1627,8 @@
"mbid": null
},
"Rufus - Ain't Nobody.opus": {
"year": null,
"date": null,
"year": 1983,
"date": "1983",
"title": "Ain't Nobody",
"artist": "Rufus, Chaka Khan",
"mbid": null
@@ -1830,8 +1830,8 @@
"mbid": null
},
"The Chordettes - Lollipop.opus": {
"year": 1987,
"date": "1987",
"year": 1959,
"date": "1959",
"title": "Lollipop",
"artist": "The Chordettes",
"mbid": "ed626d61-415e-4a4c-bcc0-89805243ab8b"
@@ -2012,8 +2012,8 @@
"mbid": "4d89c734-db46-4418-86c0-3f00814412bd"
},
"T'pau - China In Your Hand (Single Version).opus": {
"year": 2009,
"date": "2009-06-08",
"year": 1987,
"date": "1987",
"title": "China In Your Hand (Single Version)",
"artist": "T'pau",
"mbid": "56a5d0fc-a0c3-4e07-91b5-0c8c77b43ab2"

View File

@@ -204,7 +204,9 @@ export class AudioStreamingService {
* Set common caching headers
*/
private setCommonHeaders(ctx: Context): void {
ctx.response.headers.set('Cache-Control', 'no-store');
// Allow caching of audio content to prevent redundant range requests
// The token system already provides security
ctx.response.headers.set('Cache-Control', 'public, max-age=3600');
ctx.response.headers.set('Accept-Ranges', 'bytes');
}
}

View File

@@ -51,6 +51,7 @@ export class HttpServer {
ctx.response.headers.set('Access-Control-Allow-Origin', this.config.corsOrigin);
ctx.response.headers.set('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
ctx.response.headers.set('Access-Control-Allow-Headers', 'Content-Type, Range');
ctx.response.headers.set('Access-Control-Expose-Headers', 'Content-Range, Content-Length, Accept-Ranges');
if (ctx.request.method === 'OPTIONS') {
ctx.response.status = 204;

View File

@@ -79,6 +79,13 @@ export function handlePlayTrack(msg) {
try {
$audio.preload = 'auto';
} catch {}
// Reset audio state before setting new source
try {
$audio.pause();
$audio.currentTime = 0;
} catch {}
$audio.src = t.url;
const pf = document.getElementById('progressFill');
if (pf) pf.style.width = '0%';
@@ -93,7 +100,7 @@ export function handlePlayTrack(msg) {
const localStart = now + offsetMs;
const delay = Math.max(0, localStart - now);
setTimeout(() => {
$audio.currentTime = 0;
// Don't reset currentTime again - it's already 0 from above
$audio.play().catch(() => {});
const disc = document.getElementById('recordDisc');
if (disc) disc.classList.add('spin-record');

File diff suppressed because it is too large Load Diff