Spaces:
Running
Running
File size: 1,450 Bytes
ee0bba4 2b10722 ee0bba4 2b10722 ee0bba4 2b10722 ee0bba4 2b10722 ee0bba4 2b10722 ee0bba4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# Base Image
FROM node:20-slim
# Set working directory
WORKDIR /app
# Install system dependencies (needed for some npm packages)
RUN apt-get update && apt-get install -y \
python3 \
make \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Copy package files first for better layer caching
COPY package.json package-lock.json ./
# Install all dependencies including dev dependencies (needed for TypeScript build)
# Don't set NODE_ENV=production yet, so devDependencies are installed
RUN npm ci && npm cache clean --force
# Copy source code and config files
COPY tsconfig.json ./
COPY ormconfig.ts ./
COPY src ./src
COPY start.sh ./
# Build TypeScript (migrations will be compiled to dist/migrations/*.js)
# Use --verbose flag to see detailed errors
RUN npm run build 2>&1 || (echo "TypeScript compilation failed. Check errors above." && exit 1)
# Verify build succeeded - check key files exist
RUN test -f dist/index.js || (echo "Build failed: dist/index.js not found" && exit 1)
RUN test -d dist/migrations || echo "Warning: migrations directory not found"
RUN test -f dist/scripts/run-migrations.js || echo "Warning: migration script not found"
# Remove dev dependencies after build
RUN npm prune --production
# Set NODE_ENV for production runtime
ENV NODE_ENV=production
# Make startup script executable
RUN chmod +x ./start.sh
# Expose port (Hugging Face Spaces uses 7860)
EXPOSE 7860
# Use the startup script
CMD ["./start.sh"]
|