Spaces:
Build error
Build error
optimize the dockerfile a bit
Browse files- Dockerfile +24 -24
Dockerfile
CHANGED
@@ -1,35 +1,35 @@
|
|
1 |
FROM ubuntu:22.04
|
2 |
|
3 |
-
# The site space name must be passed as an environment variable
|
4 |
-
# https://huggingface.co/docs/hub/spaces-sdks-docker#buildtime
|
5 |
-
ARG STATIC_SPACE
|
6 |
-
|
7 |
# Install Node.js 22 - https://github.com/nodesource/distributions?tab=readme-ov-file#installation-instructions-deb
|
8 |
-
|
9 |
-
RUN apt
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
# Build the app
|
14 |
WORKDIR /tmp/app
|
15 |
COPY svelte-demo/ ./
|
16 |
-
RUN npm ci
|
17 |
-
RUN npm rebuild
|
18 |
-
RUN npm run build
|
19 |
|
20 |
-
#
|
21 |
-
|
22 |
-
|
23 |
-
RUN pip install --upgrade "huggingface_hub[cli]"
|
24 |
-
# Replace the site space with the new build
|
25 |
-
RUN mv /tmp/app/dist /tmp/space
|
26 |
-
WORKDIR /tmp/space
|
27 |
# The Hugging Face token must be passed as a secret (https://huggingface.co/docs/hub/spaces-sdks-docker#buildtime)
|
28 |
-
# 1. get README.md from the
|
29 |
-
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true
|
30 |
-
|
31 |
-
# 2. upload the new build to the
|
32 |
-
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true
|
|
|
33 |
|
34 |
# Halt execution because the code space is not meant to run.
|
35 |
RUN exit 1
|
|
|
1 |
FROM ubuntu:22.04
|
2 |
|
|
|
|
|
|
|
|
|
3 |
# Install Node.js 22 - https://github.com/nodesource/distributions?tab=readme-ov-file#installation-instructions-deb
|
4 |
+
# And python3
|
5 |
+
RUN apt update \
|
6 |
+
&& apt install -y curl python3 python3-pip \
|
7 |
+
&& rm -rf /var/lib/apt/lists/*
|
8 |
+
|
9 |
+
RUN curl -fsSL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh \
|
10 |
+
&& bash nodesource_setup.sh \
|
11 |
+
&& apt update \
|
12 |
+
&& apt install -y nodejs \
|
13 |
+
&& rm -rf /var/lib/apt/lists/* \
|
14 |
+
&& rm nodesource_setup.sh
|
15 |
+
|
16 |
+
RUN pip install --upgrade "huggingface_hub[cli]"
|
17 |
+
|
18 |
# Build the app
|
19 |
WORKDIR /tmp/app
|
20 |
COPY svelte-demo/ ./
|
21 |
+
RUN npm ci && npm rebuild && npm run build
|
|
|
|
|
22 |
|
23 |
+
# The static space name must be passed as an environment variable
|
24 |
+
# https://huggingface.co/docs/hub/spaces-sdks-docker#buildtime
|
25 |
+
ARG STATIC_SPACE
|
|
|
|
|
|
|
|
|
26 |
# The Hugging Face token must be passed as a secret (https://huggingface.co/docs/hub/spaces-sdks-docker#buildtime)
|
27 |
+
# 1. get README.md from the static space
|
28 |
+
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true \
|
29 |
+
huggingface-cli download --token=$(cat /run/secrets/HF_TOKEN) --repo-type=space --local-dir=. $STATIC_SPACE README.md && rm -rf ./.cache
|
30 |
+
# 2. upload the new build to the static space, including README.md
|
31 |
+
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true \
|
32 |
+
huggingface-cli upload --token=$(cat /run/secrets/HF_TOKEN) --repo-type=space $STATIC_SPACE /tmp/app/dist . --delete "*"
|
33 |
|
34 |
# Halt execution because the code space is not meant to run.
|
35 |
RUN exit 1
|