abc123 / crossword-app /Dockerfile
vimalk78's picture
Dockerized
88452f7
raw
history blame
852 Bytes
# Use Node.js 18 as base image
FROM node:18-alpine
# Set working directory
WORKDIR /app
# Copy package files for both frontend and backend
COPY frontend/package*.json ./frontend/
COPY backend/package*.json ./backend/
# Install dependencies for both frontend and backend
RUN cd frontend && npm ci
RUN cd backend && npm ci --only=production
# Copy source code
COPY frontend/ ./frontend/
COPY backend/ ./backend/
# Build the React frontend
RUN cd frontend && npm run build
# Copy built frontend files to backend public directory
RUN mkdir -p backend/public && cp -r frontend/dist/* backend/public/
# Set working directory to backend for runtime
WORKDIR /app/backend
# Expose port 7860 (Hugging Face Spaces standard)
EXPOSE 7860
# Set environment to production
ENV NODE_ENV=production
ENV PORT=7860
# Start the backend server
CMD ["npm", "start"]