Spaces:
Runtime error
Runtime error
File size: 1,233 Bytes
98da12a 13df045 ac72290 13df045 c6f43ec 13df045 c6f43ec 13df045 fbb50b2 c6f43ec 13df045 fbb50b2 13df045 c6f43ec 33ca400 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
FROM node:20-alpine AS builder
# Build the app
WORKDIR /usr/app
COPY ./ /usr/app
RUN npm install
RUN npm run sources && npm run build
# Upload the app
## Install python3 and pip
RUN apk add --no-cache python3 py3-pip
## Create and activate a virtual environment
RUN python3 -m venv /venv
ENV PATH="/venv/bin:$PATH"
RUN pip install --upgrade "huggingface_hub[cli]"
## The site space name must be passed as an environment variable
## https://huggingface.co/docs/hub/spaces-sdks-docker#buildtime
ARG STATIC_SPACE
## The Hugging Face token must be passed as a secret (https://huggingface.co/docs/hub/spaces-sdks-docker#buildtime)
## 1. get README.md from the site space
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true \
huggingface-cli download --token=$(cat /run/secrets/HF_TOKEN) --repo-type=space --local-dir=/usr/app/build $STATIC_SPACE README.md && rm -rf /usr/app/build/.cache
## 2. upload the new build to the site space, including README.md
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true \
huggingface-cli upload --token=$(cat /run/secrets/HF_TOKEN) --repo-type=space $STATIC_SPACE /usr/app/build . --delete "*"
## Halt execution because the code space is not meant to run.
CMD ["true"] |