datamk commited on
Commit
fb43d41
·
verified ·
1 Parent(s): 8f5d9e5

Upload 63 files

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -12
Dockerfile CHANGED
@@ -1,34 +1,43 @@
1
- # Use full node image for a stable build environment
2
  FROM node:20
3
 
4
- # Hugging Face specific user setup (UID 1000)
 
 
 
 
 
 
 
 
 
 
5
  RUN useradd -m -u 1000 user
6
  USER user
7
  ENV HOME=/home/user \
8
- PATH=/home/user/.local/bin:$PATH
 
 
9
 
10
  WORKDIR $HOME/app
11
 
12
- # Copy dependency manifests with correct permissions
13
  COPY --chown=user package*.json ./
 
 
14
 
15
- # Install dependencies (including optional ones like tfjs-node)
16
- RUN npm install --legacy-peer-deps
17
-
18
- # Copy the rest of the application code
19
  COPY --chown=user . .
20
 
21
- # Build the frontend with increased memory limit for Vite/Rollup
22
  ENV NODE_OPTIONS="--max-old-space-size=4096"
23
  RUN CI=false npm run build
24
 
25
- # Ensure the uploads directory exists and is writable
26
  RUN mkdir -p server/uploads
27
 
28
- # Environment variables for production
29
  ENV NODE_ENV=production
30
  ENV PORT=7860
31
  EXPOSE 7860
32
 
33
- # Start the application
34
  CMD ["node", "server/index.js"]
 
1
+ # Use a standard node image
2
  FROM node:20
3
 
4
+ # 1. Install system dependencies as ROOT
5
+ # These are strictly required to compile @tensorflow/tfjs-node and sharp
6
+ RUN apt-get update && apt-get install -y --no-install-recommends \
7
+ python3 \
8
+ make \
9
+ g++ \
10
+ libvips-dev \
11
+ ca-certificates \
12
+ && rm -rf /var/lib/apt/lists/*
13
+
14
+ # 2. Setup the Hugging Face user
15
  RUN useradd -m -u 1000 user
16
  USER user
17
  ENV HOME=/home/user \
18
+ PATH=/home/user/.local/bin:$PATH \
19
+ # Ensure TFJS doesn't crash if it can't find specific CPU optimizations
20
+ TF_CPP_MIN_LOG_LEVEL=2
21
 
22
  WORKDIR $HOME/app
23
 
24
+ # 3. Handle dependencies
25
  COPY --chown=user package*.json ./
26
+ # Use --include=optional to ensure tfjs-node is attempted
27
+ RUN npm install --legacy-peer-deps --include=optional
28
 
29
+ # 4. Copy and Build
 
 
 
30
  COPY --chown=user . .
31
 
32
+ # Increase memory for the build process
33
  ENV NODE_OPTIONS="--max-old-space-size=4096"
34
  RUN CI=false npm run build
35
 
36
+ # Final setup
37
  RUN mkdir -p server/uploads
38
 
 
39
  ENV NODE_ENV=production
40
  ENV PORT=7860
41
  EXPOSE 7860
42
 
 
43
  CMD ["node", "server/index.js"]