feat: optimize Dockerfile for HuggingFace Spaces deployment
Browse files- Dockerfile +8 -3
Dockerfile
CHANGED
|
@@ -26,6 +26,7 @@ FROM base AS web-builder
|
|
| 26 |
|
| 27 |
# Install Node.js and build tools
|
| 28 |
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
|
|
|
| 29 |
apt-get install -y nodejs && \
|
| 30 |
npm install -g yarn
|
| 31 |
|
|
@@ -39,7 +40,10 @@ WORKDIR /app/web
|
|
| 39 |
# Install dependencies and build
|
| 40 |
RUN yarn install --frozen-lockfile && \
|
| 41 |
yarn add --dev autoprefixer postcss tailwindcss code-inspector-plugin && \
|
| 42 |
-
yarn build && \
|
|
|
|
|
|
|
|
|
|
| 43 |
yarn cache clean
|
| 44 |
|
| 45 |
# ============================================
|
|
@@ -87,8 +91,9 @@ RUN mkdir -p api web && chown -R user:user /app
|
|
| 87 |
COPY --from=python-builder --chown=user /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
|
| 88 |
COPY --chown=user api/ /app/api/
|
| 89 |
|
| 90 |
-
# Copy Next.js files
|
| 91 |
-
|
|
|
|
| 92 |
COPY --from=web-builder --chown=user /app/web/.next/static /app/web/.next/static
|
| 93 |
COPY --from=web-builder --chown=user /app/web/public /app/web/public
|
| 94 |
|
|
|
|
| 26 |
|
| 27 |
# Install Node.js and build tools
|
| 28 |
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
| 29 |
+
apt-get update && \
|
| 30 |
apt-get install -y nodejs && \
|
| 31 |
npm install -g yarn
|
| 32 |
|
|
|
|
| 40 |
# Install dependencies and build
|
| 41 |
RUN yarn install --frozen-lockfile && \
|
| 42 |
yarn add --dev autoprefixer postcss tailwindcss code-inspector-plugin && \
|
| 43 |
+
NEXT_TELEMETRY_DISABLED=1 yarn build && \
|
| 44 |
+
mkdir -p .next/standalone && \
|
| 45 |
+
cp -r .next/static .next/standalone/.next/ && \
|
| 46 |
+
cp -r public .next/standalone/ && \
|
| 47 |
yarn cache clean
|
| 48 |
|
| 49 |
# ============================================
|
|
|
|
| 91 |
COPY --from=python-builder --chown=user /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
|
| 92 |
COPY --chown=user api/ /app/api/
|
| 93 |
|
| 94 |
+
# Copy Next.js files with explicit directory creation
|
| 95 |
+
RUN mkdir -p /app/web/.next/standalone /app/web/.next/static
|
| 96 |
+
COPY --from=web-builder --chown=user /app/web/.next/standalone /app/web/.next/standalone
|
| 97 |
COPY --from=web-builder --chown=user /app/web/.next/static /app/web/.next/static
|
| 98 |
COPY --from=web-builder --chown=user /app/web/public /app/web/public
|
| 99 |
|