Spaces:
Running
Running
Avijit Ghosh
commited on
Commit
·
182e10c
1
Parent(s):
509e21e
added docker
Browse files- Dockerfile +9 -5
Dockerfile
CHANGED
|
@@ -6,8 +6,10 @@ FROM node:18-bullseye-slim AS builder
|
|
| 6 |
WORKDIR /app
|
| 7 |
|
| 8 |
# install build deps and copy package files first for caching
|
|
|
|
|
|
|
| 9 |
COPY package*.json ./
|
| 10 |
-
RUN npm
|
| 11 |
|
| 12 |
# copy source and build
|
| 13 |
COPY . ./
|
|
@@ -17,7 +19,6 @@ FROM node:18-bullseye-slim AS runner
|
|
| 17 |
WORKDIR /app
|
| 18 |
|
| 19 |
ENV NODE_ENV=production
|
| 20 |
-
ENV PORT=3000
|
| 21 |
|
| 22 |
# minimal packages for certificates (if needed by model download / https)
|
| 23 |
RUN apt-get update && apt-get install -y ca-certificates --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
|
@@ -27,12 +28,15 @@ COPY --from=builder /app/package*.json ./
|
|
| 27 |
COPY --from=builder /app/node_modules ./node_modules
|
| 28 |
COPY --from=builder /app/.next ./.next
|
| 29 |
COPY --from=builder /app/public ./public
|
| 30 |
-
COPY --from=builder /app/next.config.
|
| 31 |
|
| 32 |
-
# Expose
|
|
|
|
| 33 |
EXPOSE 3000
|
| 34 |
|
| 35 |
# If you use private/gated HF models, set HF_TOKEN in the Space secrets and expose here
|
| 36 |
# e.g. in Space settings: add secret HF_TOKEN with your token
|
| 37 |
|
| 38 |
-
|
|
|
|
|
|
|
|
|
| 6 |
WORKDIR /app
|
| 7 |
|
| 8 |
# install build deps and copy package files first for caching
|
| 9 |
+
# NOTE: this repository uses pnpm lockfile but no package-lock.json; `npm ci` requires
|
| 10 |
+
# a package-lock.json and will fail. Use `npm install` so the image builds reliably.
|
| 11 |
COPY package*.json ./
|
| 12 |
+
RUN npm install --silent
|
| 13 |
|
| 14 |
# copy source and build
|
| 15 |
COPY . ./
|
|
|
|
| 19 |
WORKDIR /app
|
| 20 |
|
| 21 |
ENV NODE_ENV=production
|
|
|
|
| 22 |
|
| 23 |
# minimal packages for certificates (if needed by model download / https)
|
| 24 |
RUN apt-get update && apt-get install -y ca-certificates --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
|
|
|
| 28 |
COPY --from=builder /app/node_modules ./node_modules
|
| 29 |
COPY --from=builder /app/.next ./.next
|
| 30 |
COPY --from=builder /app/public ./public
|
| 31 |
+
COPY --from=builder /app/next.config.mjs ./next.config.mjs
|
| 32 |
|
| 33 |
+
# Expose a common port (informational). Hugging Face Spaces will inject $PORT at runtime
|
| 34 |
+
# and the CMD below ensures Next listens on that port. Do not hardcode PORT here.
|
| 35 |
EXPOSE 3000
|
| 36 |
|
| 37 |
# If you use private/gated HF models, set HF_TOKEN in the Space secrets and expose here
|
| 38 |
# e.g. in Space settings: add secret HF_TOKEN with your token
|
| 39 |
|
| 40 |
+
# Ensure `next start` uses the $PORT provided by the Spaces runtime. We use a shell
|
| 41 |
+
# wrapper so the environment variable is expanded at container runtime.
|
| 42 |
+
CMD ["sh", "-c", "npm run start -- -p ${PORT:-3000}"]
|