NitinBot001 commited on
Commit
c31a175
·
verified ·
1 Parent(s): 1cd7554

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -16
Dockerfile CHANGED
@@ -1,43 +1,52 @@
1
- # Use Node 20 on Alpine (lightweight)
 
 
2
  FROM node:20-alpine AS base
3
  ENV PNPM_HOME="/pnpm"
4
  ENV PATH="$PNPM_HOME:$PATH"
5
  RUN corepack enable
6
 
7
  # ---------------------------------------
8
- # Build Stage
9
  # ---------------------------------------
10
  FROM base AS builder
11
  WORKDIR /app
12
- COPY package.json pnpm-lock.yaml ./
13
- RUN pnpm install --frozen-lockfile
 
 
 
 
 
 
14
  COPY . .
15
- # Build the remix app
 
16
  RUN pnpm run build
17
 
18
  # ---------------------------------------
19
- # Production Stage (Hugging Face Optimized)
20
  # ---------------------------------------
21
  FROM base AS runner
22
  WORKDIR /app
23
 
24
- # Create a non-root user (HF security requirement)
25
- # Node images usually come with a 'node' user (uid 1000), which matches HF default
 
 
 
26
  USER node
27
 
 
28
  COPY --from=builder --chown=node:node /app/package.json ./
29
  COPY --from=builder --chown=node:node /app/node_modules ./node_modules
30
  COPY --from=builder --chown=node:node /app/build ./build
 
31
  COPY --from=builder --chown=node:node /app/public ./public
32
- # Copy the remix server adapter if separate, but usually built into build/server
33
-
34
- # Set standard HF port
35
- ENV PORT=7860
36
- ENV NODE_ENV=production
37
 
38
- # Expose the HF port
39
  EXPOSE 7860
40
 
41
- # Start the remix server
42
- # Note: We bind to 0.0.0.0 to allow external access within the Space
43
  CMD ["pnpm", "run", "start", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # ---------------------------------------
2
+ # 1. Base Setup
3
+ # ---------------------------------------
4
  FROM node:20-alpine AS base
5
  ENV PNPM_HOME="/pnpm"
6
  ENV PATH="$PNPM_HOME:$PATH"
7
  RUN corepack enable
8
 
9
  # ---------------------------------------
10
+ # 2. Build Stage
11
  # ---------------------------------------
12
  FROM base AS builder
13
  WORKDIR /app
14
+
15
+ # FIXED: Only copy package.json first (removes pnpm-lock.yaml dependency)
16
+ COPY package.json ./
17
+
18
+ # FIXED: Removed --frozen-lockfile so it generates the lockfile on the fly
19
+ RUN pnpm install
20
+
21
+ # Now copy the rest of the source code
22
  COPY . .
23
+
24
+ # Build the application
25
  RUN pnpm run build
26
 
27
  # ---------------------------------------
28
+ # 3. Production Stage (Hugging Face Optimized)
29
  # ---------------------------------------
30
  FROM base AS runner
31
  WORKDIR /app
32
 
33
+ # Set production environment
34
+ ENV NODE_ENV=production
35
+ ENV PORT=7860
36
+
37
+ # Create a non-root user (Matches Hugging Face ID 1000)
38
  USER node
39
 
40
+ # Copy necessary files with correct ownership
41
  COPY --from=builder --chown=node:node /app/package.json ./
42
  COPY --from=builder --chown=node:node /app/node_modules ./node_modules
43
  COPY --from=builder --chown=node:node /app/build ./build
44
+ # Some Bolt versions put public assets here, copying just in case
45
  COPY --from=builder --chown=node:node /app/public ./public
 
 
 
 
 
46
 
47
+ # Expose the specific Hugging Face port
48
  EXPOSE 7860
49
 
50
+ # Start command
51
+ # We explicitly bind to 0.0.0.0 so external traffic can reach the container
52
  CMD ["pnpm", "run", "start", "--host", "0.0.0.0", "--port", "7860"]