StyleGPT-milestone2 / Dockerfile
nexusbert's picture
commit docker
2b10722
# 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"]