AntDX316
commited on
Commit
·
0a25a37
1
Parent(s):
fb2f715
updated
Browse files- Dockerfile +16 -5
- README.md +28 -0
- docker-compose.yml +3 -1
- start.sh +15 -0
Dockerfile
CHANGED
@@ -17,11 +17,22 @@ RUN npm install || npm install --legacy-peer-deps || npm install --no-fund --no-
|
|
17 |
# Build the application
|
18 |
RUN npm run build
|
19 |
|
20 |
-
# Install a simple HTTP server to serve static content
|
21 |
-
RUN npm install -g serve
|
22 |
|
23 |
-
#
|
|
|
|
|
|
|
|
|
24 |
EXPOSE 3000
|
25 |
|
26 |
-
#
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
# Build the application
|
18 |
RUN npm run build
|
19 |
|
20 |
+
# Install a simple HTTP server to serve static content and curl for healthcheck
|
21 |
+
RUN npm install -g serve && apk add --no-cache curl
|
22 |
|
23 |
+
# Make port configurable via environment variable with 7860 as default (common for HF Spaces)
|
24 |
+
ENV PORT=7860
|
25 |
+
|
26 |
+
# Expose both common ports
|
27 |
+
EXPOSE 7860
|
28 |
EXPOSE 3000
|
29 |
|
30 |
+
# Add health check
|
31 |
+
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
32 |
+
CMD curl -f http://localhost:${PORT}/ || exit 1
|
33 |
+
|
34 |
+
# Make startup script executable
|
35 |
+
RUN chmod +x start.sh
|
36 |
+
|
37 |
+
# Run the app using our startup script
|
38 |
+
CMD ["/bin/sh", "./start.sh"]
|
README.md
CHANGED
@@ -7,4 +7,32 @@ sdk: docker
|
|
7 |
pinned: false
|
8 |
---
|
9 |
|
|
|
|
|
10 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
pinned: false
|
8 |
---
|
9 |
|
10 |
+
# HF-Shapes
|
11 |
+
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
13 |
+
|
14 |
+
## Docker Setup
|
15 |
+
|
16 |
+
This project uses Docker for containerization. The default configuration runs on port 7860 which is compatible with Hugging Face Spaces.
|
17 |
+
|
18 |
+
### Running with Docker
|
19 |
+
|
20 |
+
```bash
|
21 |
+
# Build and start the container
|
22 |
+
docker compose up app
|
23 |
+
|
24 |
+
# For development with hot-reloading
|
25 |
+
docker compose up dev
|
26 |
+
```
|
27 |
+
|
28 |
+
### Environment Variables
|
29 |
+
|
30 |
+
- `PORT`: The port on which the server will run (default: 7860)
|
31 |
+
|
32 |
+
### Troubleshooting
|
33 |
+
|
34 |
+
If you encounter issues with the container starting:
|
35 |
+
|
36 |
+
1. Check if the port 7860 is already in use
|
37 |
+
2. Ensure the application built successfully
|
38 |
+
3. Review the container logs for more details
|
docker-compose.yml
CHANGED
@@ -6,7 +6,9 @@ services:
|
|
6 |
context: .
|
7 |
dockerfile: Dockerfile
|
8 |
ports:
|
9 |
-
- "
|
|
|
|
|
10 |
restart: unless-stopped
|
11 |
|
12 |
# Development service with fallback options for npm
|
|
|
6 |
context: .
|
7 |
dockerfile: Dockerfile
|
8 |
ports:
|
9 |
+
- "7860:7860"
|
10 |
+
environment:
|
11 |
+
- PORT=7860
|
12 |
restart: unless-stopped
|
13 |
|
14 |
# Development service with fallback options for npm
|
start.sh
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/sh
|
2 |
+
set -e
|
3 |
+
|
4 |
+
# Print environment for debugging
|
5 |
+
echo "Environment variables:"
|
6 |
+
printenv | grep -v PASSWORD | grep -v SECRET
|
7 |
+
|
8 |
+
# Set default port if not provided
|
9 |
+
if [ -z "$PORT" ]; then
|
10 |
+
echo "PORT not set, defaulting to 7860"
|
11 |
+
export PORT=7860
|
12 |
+
fi
|
13 |
+
|
14 |
+
echo "Starting server on port $PORT"
|
15 |
+
serve -s dist -l $PORT
|