Spaces:
Runtime error
Runtime error
Commit
·
a3bdf98
1
Parent(s):
36e99f7
setup docker code space
Browse files- Dockerfile +39 -17
- README.md +2 -3
- docker-compose.yml +0 -14
Dockerfile
CHANGED
@@ -1,17 +1,39 @@
|
|
1 |
-
FROM
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM ubuntu:22.04
|
2 |
+
|
3 |
+
# Install Node.js 20 - 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_20.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 /usr/app
|
20 |
+
COPY ./ /usr/app
|
21 |
+
RUN npm install
|
22 |
+
RUN npm run sources && npm run build
|
23 |
+
|
24 |
+
|
25 |
+
# Upload the app
|
26 |
+
|
27 |
+
## The site space name must be passed as an environment variable
|
28 |
+
## https://huggingface.co/docs/hub/spaces-sdks-docker#buildtime
|
29 |
+
ARG STATIC_SPACE
|
30 |
+
## The Hugging Face token must be passed as a secret (https://huggingface.co/docs/hub/spaces-sdks-docker#buildtime)
|
31 |
+
## 1. get README.md from the site space
|
32 |
+
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true
|
33 |
+
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
|
34 |
+
## 2. upload the new build to the site space, including README.md
|
35 |
+
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true
|
36 |
+
huggingface-cli upload --token=$(cat /run/secrets/HF_TOKEN) --repo-type=space $STATIC_SPACE /usr/app/build . --delete "*"
|
37 |
+
|
38 |
+
## Halt execution because the code space is not meant to run.
|
39 |
+
CMD ["true"]
|
README.md
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
---
|
2 |
-
title: Hub Stats
|
3 |
-
emoji:
|
4 |
colorFrom: red
|
5 |
colorTo: yellow
|
6 |
sdk: docker
|
7 |
pinned: false
|
8 |
license: apache-2.0
|
9 |
-
app_port: 3000
|
10 |
---
|
11 |
# Hugging Face Hub Stats
|
12 |
|
|
|
1 |
---
|
2 |
+
title: Hub Stats Code Space
|
3 |
+
emoji: 🤖
|
4 |
colorFrom: red
|
5 |
colorTo: yellow
|
6 |
sdk: docker
|
7 |
pinned: false
|
8 |
license: apache-2.0
|
|
|
9 |
---
|
10 |
# Hugging Face Hub Stats
|
11 |
|
docker-compose.yml
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
version: '3.8'
|
2 |
-
|
3 |
-
services:
|
4 |
-
app:
|
5 |
-
build:
|
6 |
-
context: .
|
7 |
-
dockerfile: Dockerfile
|
8 |
-
ports:
|
9 |
-
- "3000:3000"
|
10 |
-
volumes:
|
11 |
-
- .:/app
|
12 |
-
- /app/node_modules
|
13 |
-
environment:
|
14 |
-
- NODE_ENV=production
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|