Spaces:
Running
Running
coyotte508
commited on
Commit
·
903c838
1
Parent(s):
6055127
first commit
Browse files- Dockerfile +26 -0
- build.sh +44 -0
Dockerfile
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use a base image with Python and Node.js pre-installed
|
2 |
+
FROM node:22-bullseye-slim
|
3 |
+
|
4 |
+
# Install Python and pip
|
5 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
6 |
+
python3 \
|
7 |
+
python3-pip \
|
8 |
+
&& rm -rf /var/lib/apt/lists/*
|
9 |
+
|
10 |
+
# Install corepack (for pnpm and yarn) and make them available
|
11 |
+
RUN corepack enable \
|
12 |
+
&& corepack prepare pnpm@latest --activate \
|
13 |
+
&& corepack prepare yarn@latest --activate
|
14 |
+
|
15 |
+
# Install huggingface_hub and huggingface_hub[cli]
|
16 |
+
RUN pip install -U "huggingface_hub[cli]"
|
17 |
+
|
18 |
+
# Define a working directory
|
19 |
+
WORKDIR /app
|
20 |
+
|
21 |
+
# Copy the script that will handle the build process
|
22 |
+
COPY build.sh /app/build.sh
|
23 |
+
RUN chmod +x /app/build.sh
|
24 |
+
|
25 |
+
# Command to run the build script
|
26 |
+
CMD ["/app/build.sh"]
|
build.sh
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
# Add safety measures
|
3 |
+
set -e
|
4 |
+
set -o pipefail
|
5 |
+
|
6 |
+
# Check if all required environment variables are set
|
7 |
+
if [ -z "$HF_TOKEN" ] || [ -z "$HF_SPACE_NAME" ] || [ -z "$BUILD_COMMAND" ] || [ -z "$OUTPUT_PATH" ]; then
|
8 |
+
echo "Missing required environment variables"
|
9 |
+
exit 1
|
10 |
+
fi
|
11 |
+
|
12 |
+
# Set the Hugging Face token
|
13 |
+
export HF_HUB_ACCESS_TOKEN=$HF_TOKEN
|
14 |
+
|
15 |
+
# Download the space
|
16 |
+
huggingface-cli download spaces/$HF_SPACE_NAME -d space
|
17 |
+
|
18 |
+
# Change directory to the space's directory
|
19 |
+
cd space
|
20 |
+
|
21 |
+
# Determine which package manager to use
|
22 |
+
if [ -f "package.json" ]; then
|
23 |
+
if [ -f "pnpm-lock.yaml" ]; then
|
24 |
+
pnpm install
|
25 |
+
elif [ -f "yarn.lock" ]; then
|
26 |
+
yarn install
|
27 |
+
else
|
28 |
+
npm install
|
29 |
+
fi
|
30 |
+
else
|
31 |
+
echo "No package.json found. Assuming no package manager is needed."
|
32 |
+
fi
|
33 |
+
|
34 |
+
echo "Running the build command: $BUILD_COMMAND"
|
35 |
+
|
36 |
+
# Run the build command
|
37 |
+
eval $BUILD_COMMAND
|
38 |
+
|
39 |
+
echo "Build completed successfully, uploading the build output..."
|
40 |
+
|
41 |
+
# Upload the build output to the Hugging Face space
|
42 |
+
huggingface-cli upload spaces/$HF_SPACE_NAME $OUTPUT_PATH / --revision refs/convert/build --token $HF_TOKEN
|
43 |
+
|
44 |
+
echo "Build and upload completed successfully."
|