Press "Enter" to skip to content

基于HFS构建一个容器上运行的简单文件服务器

一起一直在使用hfs服务来搭建简单文件服务器, https://www.rejetto.com/hfs/

hfs用起来还是比较舒服的,但是这个服务是Delphi实现的,windows上面跑比较方便,但是我现在都比较喜欢什么东西都扔到docker里面运行。

后来我找到个 https://github.com/rejetto/hfs 使用Typescript重写的,他有Linux的发行版,可以尝试打包成docker来方便部署。

下面整理下docker部署的相关文件

Dockerfile

FROM ubuntu

#ADD https://github.com/rejetto/hfs/releases/download/v0.51.0-beta9/hfs-linux.zip /opt
ADD hfs-linux.zip /opt
#dockerfile的ADD指令不会解压zip文件,需要我们自己解压
RUN apt-get update -y
RUN apt-get install zip unzip -y
RUN unzip /opt/hfs-linux.zip
#默认配置文件,主要是带个初始密码
ADD .config.yaml /root/.hfs/config.yaml
ENTRYPOINT ["/hfs"]

配置文件 .config.yaml

accounts:
    admin:
        password: admin123
        admin: true
vfs:
  children:
    - source: /root/.hfs/data
      can_upload:
        - admin
      children: []

程序包:hfs-linux.zip,下载地址:https://github.com/rejetto/hfs/releases

docker-compose.yml文件

version: '3.3'
services:
  hfs:
    build: .
    image: hfs
    volumes:
      - ./data:/root/.hfs/data
      - ./config.yaml:/root/.hfs/config.yaml
    ports:
      - 8080:80
    restart: always
    logging:
      options:
        max-size: "10m"
        max-file: "10"

详细配置参考:https://github.com/rejetto/hfs/blob/main/config.md

更牛逼的方式

arm环境

from arm64v8/node

ENTRYPOINT ["npx", "-y", "hfs@latest"]

x86环境

from node

ENTRYPOINT ["npx", "-y", "hfs@latest"]
发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注