mirror of
https://github.com/donpat1to/Schichtenplaner.git
synced 2025-11-30 22:45:46 +01:00
added copying all files so package-lock findable
This commit is contained in:
61
Dockerfile
61
Dockerfile
@@ -1,7 +1,7 @@
|
|||||||
# Multi-stage build for combined frontend + backend
|
# Single stage build for workspaces
|
||||||
FROM node:20-bullseye AS backend-builder
|
FROM node:20-bullseye AS builder
|
||||||
|
|
||||||
WORKDIR /app/backend
|
WORKDIR /app
|
||||||
|
|
||||||
# Install Python + OR-Tools
|
# Install Python + OR-Tools
|
||||||
RUN apt-get update && apt-get install -y python3 python3-pip build-essential \
|
RUN apt-get update && apt-get install -y python3 python3-pip build-essential \
|
||||||
@@ -10,54 +10,21 @@ RUN apt-get update && apt-get install -y python3 python3-pip build-essential \
|
|||||||
# Create symlink so python3 is callable as python
|
# Create symlink so python3 is callable as python
|
||||||
RUN ln -sf /usr/bin/python3 /usr/bin/python
|
RUN ln -sf /usr/bin/python3 /usr/bin/python
|
||||||
|
|
||||||
# Copy root package files
|
# Copy all files
|
||||||
COPY package*.json ./
|
COPY . .
|
||||||
COPY tsconfig.base.json ./
|
|
||||||
|
|
||||||
# Copy workspace package files
|
# Install all dependencies (workspaces)
|
||||||
COPY backend/package*.json ./backend/
|
|
||||||
COPY frontend/package*.json ./frontend/
|
|
||||||
|
|
||||||
# Install backend dependencies
|
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
# Copy source code
|
|
||||||
COPY backend/ ./backend/
|
|
||||||
COPY frontend/ ./frontend/
|
|
||||||
|
|
||||||
# Build backend
|
# Build backend
|
||||||
RUN npm run build --workspace=backend
|
RUN npm run build --workspace=backend
|
||||||
|
|
||||||
# Build frontend
|
# Build frontend
|
||||||
RUN npm run build --workspace=frontend
|
RUN npm run build --workspace=frontend
|
||||||
|
|
||||||
# Copy database files manually
|
|
||||||
RUN cp -r src/database/ dist/database/
|
|
||||||
|
|
||||||
# Verify Python and OR-Tools installation
|
# Verify Python and OR-Tools installation
|
||||||
RUN python -c "from ortools.sat.python import cp_model; print('OR-Tools installed successfully')"
|
RUN python -c "from ortools.sat.python import cp_model; print('OR-Tools installed successfully')"
|
||||||
|
|
||||||
# Frontend build stage - UPDATED FOR VITE
|
|
||||||
FROM node:20-bullseye AS frontend-builder
|
|
||||||
|
|
||||||
WORKDIR /app/frontend
|
|
||||||
|
|
||||||
# Copy frontend files
|
|
||||||
COPY frontend/package*.json ./
|
|
||||||
COPY frontend/tsconfig.json ./
|
|
||||||
COPY frontend/vite.config.ts ./
|
|
||||||
COPY frontend/index.html ./
|
|
||||||
|
|
||||||
# Install frontend dependencies
|
|
||||||
RUN npm ci
|
|
||||||
|
|
||||||
# Copy frontend source
|
|
||||||
COPY frontend/src/ ./src/
|
|
||||||
COPY frontend/public/ ./public/
|
|
||||||
|
|
||||||
# Build frontend with Vite
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
# Production stage
|
# Production stage
|
||||||
FROM node:20-bookworm
|
FROM node:20-bookworm
|
||||||
|
|
||||||
@@ -70,15 +37,17 @@ RUN npm install -g pm2
|
|||||||
RUN mkdir -p /app/data
|
RUN mkdir -p /app/data
|
||||||
|
|
||||||
# Copy backend built files
|
# Copy backend built files
|
||||||
COPY --from=backend-builder /app/backend/package*.json ./
|
COPY --from=builder /app/backend/dist/ ./dist/
|
||||||
COPY --from=backend-builder /app/backend/dist/ ./dist/
|
COPY --from=builder /app/backend/package*.json ./
|
||||||
COPY --from=backend-builder /app/backend/node_modules/ ./node_modules/
|
|
||||||
|
|
||||||
# Copy frontend built files - UPDATED FOR VITE (uses 'dist' instead of 'build')
|
# Copy only production dependencies
|
||||||
COPY --from=frontend-builder /app/frontend/dist/ ./frontend-build/
|
COPY --from=builder /app/node_modules/ ./node_modules/
|
||||||
|
|
||||||
|
# Copy frontend built files
|
||||||
|
COPY --from=builder /app/frontend/dist/ ./frontend-build/
|
||||||
|
|
||||||
# Copy PM2 configuration
|
# Copy PM2 configuration
|
||||||
COPY ecosystem.config.cjs ./
|
COPY --from=builder /app/ecosystem.config.cjs ./
|
||||||
|
|
||||||
# Create a non-root user and group - DEBIAN STYLE
|
# Create a non-root user and group - DEBIAN STYLE
|
||||||
RUN groupadd -g 1001 nodejs && \
|
RUN groupadd -g 1001 nodejs && \
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"docker:build": "docker build -t schichtplan-app .",
|
"docker:build": "docker build -t schichtplan-app .",
|
||||||
"docker:run": "docker run -p 3002:3002 schichtplan-app",
|
"docker:run": "docker run -p 3002:3002 schichtplan-app",
|
||||||
"build:all": "cd backend && npm run build && cd ../frontend && npm run build"
|
"build:all": "npm run build --workspace=backend && npm run build --workspace=frontend"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
|
|||||||
Reference in New Issue
Block a user