This commit is contained in:
Andrey Kondratev
2025-08-28 16:37:59 +05:00
parent 913f833b8c
commit b8e2bf1090
23 changed files with 838 additions and 7 deletions

59
Dockerfile Normal file
View File

@@ -0,0 +1,59 @@
# Build stage
FROM node:18-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY yarn.lock* ./
# Install all dependencies (including dev for build)
RUN npm install && npm cache clean --force
# Copy source code
COPY . .
# Build the application
RUN npm run build
# Clean dev dependencies
RUN npm prune --production
# Production stage
FROM node:18-alpine AS production
# Install ffmpeg from Alpine packages (architecture-aware)
RUN apk update && apk add --no-cache ffmpeg
# Set ffmpeg paths
ENV FFMPEG_PATH=/usr/bin/ffmpeg
ENV FFPROBE_PATH=/usr/bin/ffprobe
WORKDIR /app
# Copy built application and dependencies
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/public ./public
COPY --from=builder /app/package*.json ./
# Create necessary directories
RUN mkdir -p downloads database
# Create non-root user
RUN addgroup -g 1001 -S nodejs
RUN adduser -S quixotic -u 1001
# Change ownership of app directory
RUN chown -R quixotic:nodejs /app
USER quixotic
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })"
# Start the application
CMD ["node", "dist/server.js"]