nexusbert commited on
Commit
2b10722
·
1 Parent(s): ee0bba4

commit docker

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