levisd commited on
Commit
a248f60
·
verified ·
1 Parent(s): a3dcba4

Upload 3 files

Browse files
Files changed (3) hide show
  1. Dockerfile +38 -0
  2. README.md +17 -7
  3. entrypoint.sh +11 -0
Dockerfile ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the official Rejetto HFS image as the base
2
+ FROM rejetto/hfs:latest
3
+
4
+ # Switch to root to configure permissions and users
5
+ USER root
6
+
7
+ # Create a non-root user 'user' with UID 1000
8
+ # We explicitly create the group first to ensure consistency
9
+ RUN groupadd -g 1000 user && \
10
+ useradd -m -u 1000 -g user -d /home/user/app user
11
+
12
+ # Set working directory
13
+ WORKDIR /home/user/app
14
+
15
+ # Create necessary directories for HFS and set permissions
16
+ # /data for potential persistence, /home/user/app for the application
17
+ RUN mkdir -p /data && \
18
+ chown -R user:user /home/user/app /data
19
+
20
+ # Switch to the non-root user
21
+ USER user
22
+
23
+ # Expose the port used by Hugging Face Spaces
24
+ EXPOSE 7860
25
+
26
+ # Copy the entrypoint script
27
+ COPY entrypoint.sh /entrypoint.sh
28
+ USER root
29
+ RUN chmod +x /entrypoint.sh
30
+ USER user
31
+
32
+ # Set the custom entrypoint
33
+ ENTRYPOINT ["/entrypoint.sh"]
34
+
35
+ # Command to run HFS
36
+ # We use the absolute path to the binary as found in the base image
37
+ # default CMD passed to entrypoint
38
+ CMD ["/opt/hfs/hfs", "--port", "7860", "--address", "0.0.0.0", "/data"]
README.md CHANGED
@@ -1,12 +1,22 @@
1
  ---
2
- title: HFS
3
- emoji: 🌍
4
- colorFrom: red
5
  colorTo: green
6
  sdk: docker
7
- pinned: false
8
- license: apache-2.0
9
- short_description: Access your files via web, directly from your disk.
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: HFS File Server
3
+ emoji: 📂
4
+ colorFrom: blue
5
  colorTo: green
6
  sdk: docker
7
+ app_port: 7860
 
 
8
  ---
9
 
10
+ # Rejetto HFS on Hugging Face Spaces
11
+
12
+ This is a deployment of [Rejetto HFS](https://github.com/rejetto/hfs) (HTTP File Server) on Hugging Face Spaces using the Docker SDK.
13
+
14
+ ## Configuration
15
+
16
+ - **Port**: 7860 (Default for HF Spaces)
17
+ - **Storage**: Ephemeral (Data is lost on restart unless persistent storage is attached)
18
+ - **User**: Runs as non-root user `user` (UID 1000)
19
+
20
+ ## Usage
21
+
22
+ Access the file server interface directly through the Space URL.
entrypoint.sh ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ # If HFS_PASSWORD is set, configure the admin account
5
+ if [ -n "$HFS_PASSWORD" ]; then
6
+ echo "Setting HFS admin password..."
7
+ /opt/hfs/hfs --create-admin "$HFS_PASSWORD"
8
+ fi
9
+
10
+ # Execute the passed command (CMD from Dockerfile)
11
+ exec "$@"