Refactor code structure for improved readability and maintainability

This commit is contained in:
2025-10-19 22:08:17 +02:00
parent bec0a3b72f
commit 445f522fa8
11 changed files with 2242 additions and 2182 deletions

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"]