initial commit
This commit is contained in:
44
Dockerfile
Normal file
44
Dockerfile
Normal file
@@ -0,0 +1,44 @@
|
||||
# --- Stage 1: Build Frontend ---
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy dependency files
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
# Copy source code (files in .dockerignore are excluded)
|
||||
COPY . .
|
||||
|
||||
# Build the frontend
|
||||
RUN npm run build
|
||||
|
||||
# --- Stage 2: Production Server ---
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies for sqlite3
|
||||
RUN apk add --no-cache python3 make g++
|
||||
|
||||
# Copy package files and install production dependencies
|
||||
COPY package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
|
||||
# Copy backend server and config
|
||||
COPY server.js .
|
||||
COPY metadata.json .
|
||||
|
||||
# Copy built frontend from builder stage
|
||||
COPY --from=builder /app/dist ./dist
|
||||
|
||||
# 1. Create the uploads folder explicitly
|
||||
# 2. Set ownership of the app directory to the 'node' user
|
||||
RUN mkdir -p uploads && chown -R node:node /app
|
||||
|
||||
# Switch to non-root user
|
||||
USER node
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
Reference in New Issue
Block a user