| FROM node:20-alpine | |
| # Install build dependencies | |
| RUN apk add --no-cache make gcc g++ python3 | |
| # Create app directory | |
| WORKDIR /app | |
| # Copy all application files | |
| COPY . . | |
| # Remove existing node_modules (if any) | |
| RUN rm -rf node_modules | |
| # Install dependencies | |
| RUN npm ci | |
| # Build the application | |
| RUN npm run build | |
| # Rebuild bcrypt (if necessary) | |
| RUN npm rebuild bcrypt --build-from-source | |
| # Create the dist directory and set permissions | |
| RUN mkdir -p /app/dist && chown -R node:node /app | |
| # Switch to non-root user | |
| USER node | |
| # Expose the port the app runs on | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["npm", "run", "start:dev"] |