33 lines
759 B
Docker
33 lines
759 B
Docker
# Stage 1: Build the frontend React app
|
|
FROM node:20-slim AS frontend-builder
|
|
WORKDIR /app/frontend
|
|
COPY frontend/package*.json ./
|
|
RUN npm install
|
|
COPY frontend/ ./
|
|
RUN npm run build
|
|
|
|
# Stage 2: Setup the backend and copy build output
|
|
FROM node:20-slim
|
|
WORKDIR /app
|
|
|
|
COPY backend/package*.json ./backend/
|
|
WORKDIR /app/backend
|
|
RUN npm install --only=production
|
|
|
|
# Copy backend source
|
|
COPY backend/ ./
|
|
|
|
# Copy built frontend from Stage 1 into the backend public static directory
|
|
COPY --from=frontend-builder /app/frontend/dist ./public
|
|
|
|
# Set default env variables
|
|
ENV PORT=3000
|
|
ENV NODE_ENV=production
|
|
ENV DATABASE_PATH=/app/data/database.db
|
|
|
|
# Create persistent storage folder for SQLite database
|
|
RUN mkdir -p /app/data
|
|
|
|
EXPOSE 3000
|
|
CMD ["node", "server.js"]
|