[5 Mins Docker] Deploy Zfile into Cloud - An Online Cloud Disk Listing Program - NETSEC

Latest

Learning, Sharing, Creating

Cybersecurity Memo

Saturday, January 25, 2025

[5 Mins Docker] Deploy Zfile into Cloud - An Online Cloud Disk Listing Program

This post shows you how to deploy zfile using Docker. It demonstrates the steps deploying to online cloud providers such as fly.io, Zeahur, Koyeb, . 






Zfile

Github: https://github.com/zfile-dev/zfile

ZFile is an online cloud disk (directory list) program suitable for individuals. It can unify your storage sources of various storage types into one web page for viewing, previewing, and maintenance. You no longer need to log in to various web pages to manage files. Now you only need to use it in ZFile. You only need to fill in the relevant information of the storage source. Other token refreshes and authorizations are as automated as possible, and there are complete documents to help you use it.

  • Supports docking with S3, OneDrive, SharePoint, Google Drive, Duoji Cloud, Youpai Cloud, local storage, FTP, SFTP and other storage sources
  • Supports online browsing of pictures, playing of audio and video, text files, Office, obj (3d) and other file types.

Please refer to the deployment documentation: https://docs.zfile.vip

Demo site: https://demo.zfile.vip


System features:
  • DockerDocker Composesupport (amd64/arm64)
  • Responsive design, multi-terminal compatibility
  • Support file operations: upload, download, rename, delete, create new folder, etc.
  • Same operation experience as local files, supports drag-and-drop selection, Ctrl + Left Mouse clickmultiple selection, Shift + single clickmultiple selection, Ctrl + Aselect all, and Escdeselect all
  • The upload experience is the same as local files, supporting Ctrl + Vpasting and dragging to upload files/folders .
  • Image gallery mode, and supports customizing the number of columns, spacing, and other information.
  • Folder encryption
  • Contents readmeDocumentation
  • File/Folder Hiding
  • Custom js,css
  • Support online browsing of text files, PDF, pictures, music, and videos (support mp4, flv, hls)
  • File direct link and QR code
  • Mount multiple storage policies simultaneously
  • Supports S3 protocol, Alibaba Cloud OSS, FTP, Huawei Cloud OBS, local storage, MINIO, OneDrive International/Home/Personal/21Vianet/SharePoint, , Qiniu Cloud KODO, Tencent Cloud COS, and Youpai Cloud USS.

Docker image: http://docker.io/zhaojun1998/zfile


Docker Run & Docker compose


Docker Run


docker run -d --name=zfile --restart=always \
    -p 8080:8080 \
    -v /root/zfile/db:/root/.zfile-v4/db \
    -v /root/zfile/logs:/root/.zfile-v4/logs \
    -v /root/zfile/file:/data/file \
    zhaojun1998/zfile:latest


Docker Compose:

Commands:
  • mkdir -p /root/data/docker_data/zfile
  • cd /root/data/docker_data/zfile
  • nano docker-compose.yml
docker-compose.yml file content:
version: '3.3'
services:
    zfile:
        container_name: zfile
        restart: always
        ports:
            - '8080:8080'    # change left port if needed,keep right one no changes
        volumes:
            - './db:/root/.zfile-v4/db'      # map container's db folder to current host folder/db
            - './logs:/root/.zfile-v4/logs'  # map container's log folder to host's current folder/logs
            - './data:/root/.zfile-v4/data'  # map data folder to host's current folder/data folder,later we can create a local storage source to show the content in /root/.zfile-v4/data
        image: zhaojun1998/zfile


Other Related Commands:
  • lsof -i:8080 #check if 8080 port has been occupied,if yes, change to different one, such as 8090
  • apt install lsof #install lsof
  • cd /root/data/docker_data/zfile
  • docker-compose up -d


Enterhttp://ip:8080to visit the site.

Update 

cp -r /root/data/docker_data/zfile /root/data/docker_data/zfile.archive  # backup first
cd /root/data/docker_data/zfile  # cd into docker-compose folder
docker-compose pull    # pull latest image
docker-compose up -d   # bring up the docker


Uninstall

cd /root/data/docker_data/zfile  # Enter docker-compose folder
docker-compose down    # bring down the docker
rm -rf /root/data/docker_data/zfile  # delete all data mapped to local host folders

 

Fly.io


https://fly.io/docs/about/pricing/#free-allowances
New sign up for fly.io will have to pay $5 to stay a Hobby plan after you used up $5 free trial credit. But Legacy Hobby Plan still has no monthly subscription fee. 


Free allowances. Resources included for free on all plans:
  • Up to 3 shared-cpu-1x 256mb VMs
  • 3GB persistent volume storage (total)
  • 160GB outbound data transfer

1 Sign into your Fly.io account by typing flyctl auth login

PS C:\Users\WDAGUtilityAccount> flyctl auth login
Opening https://fly.io/app/auth/cli/8e426809a69c7d38e2ca77e0f62ae57 ...

Waiting for session... Done
successfully logged in as [email protected]

You will be prompted a login window in a browser. You can use either Github or Google account to login. After logged in successfully, your flyctl should be connected to your account, as show below.



2 Install flyctl if you are using Windows machine. 
For other OS, check installation guide. The fastest way to get up and running is by installing the flyctl CLI.

PS C:\Users\john> iwr https://fly.io/install.ps1 -useb | iex                                                          Downloading flyctl...                                                                                                   flyctl was installed successfully to C:\Users\john\.fly\bin\flyctl.exe
Run 'flyctl --help' to get started
PS C:\Users\john> 


3 Close CMD or Powershell  terminal and open a new one to continue next command:

  • fly launch

For more details, check out the Install flyctl documentation
PS C:\Users\john> fly launch
Scanning source code
Could not find a Dockerfile, nor detect a runtime or framework from source code. Continuing with a blank app.
Creating app in C:\Users\john
We're about to launch your app on Fly.io. Here's what you're getting:

Organization: Johnny Netsec            (fly launch defaults to the personal org)
Name:         john-ancient-flower-3833 (generated)
Region:       Toronto, Canada          (this is the fastest region for you)
App Machines: shared-cpu-1x, 1GB RAM   (most apps need about 1GB of RAM)
Postgres:     <none>                   (not requested)
Redis:        <none>                   (not requested)
Tigris:       <none>                   (not requested)

? Do you want to tweak these settings before proceeding? No
Created app 'john-ancient-flower-3833' in organization 'personal'
Admin URL: https://fly.io/apps/john-ancient-flower-3833
Hostname: john-ancient-flower-3833.fly.dev
Wrote config file fly.toml
PS C:\Users\john>


Here are some CLI commands :


Modify fly.toml 

 

Default fly.toml file, which was generated from previous "fly launch" command


PS C:\Users\john> cat fly.toml
# fly.toml app configuration file generated for john-ancient-flower-3833 on 2025-01-22T07:43:31-05:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
app = 'john-ancient-flower-3833'
primary_region = 'yyz'
[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = 'stop'
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']
[[vm]]
  memory = '1gb'
  cpu_kind = 'shared'
  cpus = 1
PS C:\Users\john>


We have not deploied it yet. Lets modify this fly.toml file to following example for deploying zfile:


# fly.toml file generated for 51zfile
app = "51zfile"                                               # change to whatever name you want if the name is not occupied
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[build]
  image = "zhaojun1998/zfile"                                # Do not change unless you build your own image
[env]

[mounts]
  source="51zfile"                                               # change to your fly.io volume name created in next section
  destination="/root/.zfile-v4"                                      # do not change
[experimental]
  allowed_public_ports = []
  auto_rollback = true
[[services]]
  http_checks = []
  internal_port = 8080                                              # change to port 5230
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"
  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80
  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443
  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"





Create Persistent Disk



1 Create a new 1GB disk for your persistent data

  • fly volumes create 51zfile --size 1

2 Related flyctl commands

PS C:\Users\john> flyctl --help
This is flyctl, the Fly.io command line interface.
Usage:
  flyctl.exe [flags]
  flyctl.exe [command]
Deploying apps & machines
  apps         Manage apps.
  deploy       Deploy Fly applications
  launch       Create and configure a new app from source code or a Docker image
  machine      Manage Fly Machines.
  status       Show app status
Configuration & scaling
  certs        Manage certificates
  config       Manage an app's configuration
  image        Manage app image
  ips          Manage IP addresses for apps
  scale        Scale app resources
  secrets      Manage application secrets with the set and unset commands.
  volumes      Manage Fly Volumes.
Monitoring & managing things
  checks       Manage health checks
  console      Run a console in a new or existing machine
  dashboard    Open web browser on Fly Web UI for this app
  dig          Make DNS requests against Fly.io's internal DNS server
  incidents    Show incidents
  logs         View app logs
  ping         Test connectivity with ICMP ping messages
  proxy        Proxies connections to a Fly Machine.
  releases     List app releases
  services     Show the application's services
  sftp         Get or put files from a remote VM.
  ssh          Use SSH to log into or run commands on Machines
  wireguard    Commands that manage WireGuard peer connections
Databases & extensions
  consul       Enable and manage Consul clusters
  extensions   Extensions are additional functionality that can be added to your Fly apps
  litefs-cloud LiteFS Cloud management commands
  mysql        Provision and manage MySQL database clusters
  postgres     Manage Postgres clusters.
  redis        Launch and manage Redis databases managed by Upstash.com
  storage      Provision and manage Tigris object storage buckets
Access control
  auth         Manage authentication
  orgs         Commands for managing Fly organizations
  tokens       Manage Fly.io API tokens
Help & troubleshooting
  docs         View Fly documentation
  doctor       The DOCTOR command allows you to debug your Fly environment
  platform     Fly platform information
Additional Commands:
  agent        Commands that manage the Fly agent, a background process that manages flyctl wireguard connections
  completion   Generate the autocompletion script for the specified shell
  help         Help about any command
  jobs         Show jobs at Fly.io
  settings     Manage flyctl settings
  synthetics   Synthetic monitoring
  version      Show version information for the flyctl command
Flags:
  -t, --access-token string   Fly API Access Token
      --debug                 Print additional logs and traces
  -h, --help                  help for flyctl.exe
      --verbose               Verbose output
Use "flyctl.exe [command] --help" for more information about a command.
PS C:\Users\john>



3 Related flyctl volume commands


PS C:\Users\john> flyctl volume --help
Manage Fly Volumes. Volumes are persistent storage for Fly Machines. Learn how how volumes work:
https://fly.io/docs/volumes/overview/.
Usage:
  flyctl.exe volumes [command]
Aliases:
  volumes, volume, vol
Available Commands:
  create      Create a new volume for an app.
  destroy     Destroy one or more volumes.
  extend      Extend a volume to the specified size.
  fork        Fork the specified volume.
  list        List the volumes associated with an app.
  show        Show the details of the specified volume.
  snapshots   Manage volume snapshots.
  update      Update a volume for an app.
Flags:
  -h, --help   help for volumes
Global Flags:
  -t, --access-token string   Fly API Access Token
      --debug                 Print additional logs and traces
      --verbose               Verbose output
Use "flyctl.exe volumes [command] --help" for more information about a command.
PS C:\Users\john>



4 flyctl volume create 51zfile --size 1


PS C:\Users\john> flyctl volume create 51zfile --size 1
Warning! Every volume is pinned to a specific physical host. You should create two or more volumes per application to av? Do you still want to use the volumes feature? Yes
Some regions require a Launch plan or higher (bom).N) y
See https://fly.io/plans to set up a plan.
? Select region: Toronto, Canada (yyz)
                  ID: vol_remy7o667loxqel4
                Name: 51zfile
                 App: 51zfile
              Region: yyz
                Zone: 520a
             Size GB: 1
           Encrypted: true
          Created at: 22 Jan 25 16:22 UTC
  Snapshot retention: 5
 Scheduled snapshots: true
PS C:\Users\john>




PS C:\Users\john> flyctl volume list
ID                      STATE   NAME    SIZE    REGION  ZONE    ENCRYPTED       ATTACHED VM     CREATED AT
vol_remy7o667loxqel4    created 51zfile 1GB     yyz     520a    true                            2 minutes ago


Fly.io deploy




PS C:\Users\john> fly deploy
==> Verifying app config
Validating C:\Users\john\fly.toml
✓ Configuration is valid
--> Verified app config
==> Building image
Searching for image 'zhaojun1998/zfile' remotely...
image found: img_3mno4w2dy794k18q

Watch your deployment at https://fly.io/apps/51zfile/monitoring

This deployment will:
 * create 1 "app" machine

No machines in group app, launching a new machine
Finished launching new machines
-------
 ✔ Machine e82dd00f723748 [app] update finished: success
-------
Checking DNS configuration for 51zfile.fly.dev

Visit your newly deployed app at https://51zfile.fly.dev/
PS C:\Users\john>



Zeabur.com

Zeabur has a free tiral plan which gives you an opportunity to run your app for 24 hours without any charges. (Jan 22, 2025)




 Deploy through Zeabur platform;s template: https://zeabur.com/templates/441Y8R




View Source: 


services:
        - name: zfile
          icon: https://raw.githubusercontent.com/ikxin/zeabur/main/templates/zfile/icon.png
          template: PREBUILT_V2
          spec:
            source:
                image: zhaojun1998/zfile
            ports:
                - id: web
                  port: 8080
                  type: HTTP
            volumes:
                - id: db
                  dir: /root/.zfile-v4/db
                - id: logs
                  dir: /root/.zfile-v4/logs
                - id: file
                  dir: /data/file
          domainKey: PUBLIC_DOMAIN

Deploy to free trial zone :



You will get following notification from your deployed project if you are using Free Trial layer service.

This project is deployed in a free trial region and will be deleted after 24 hours.

Please select other regions for deploying production projects




Render

 https://dashboard.render.com/

Free Web Service in Hobby Plan: 512MB RAM and 0.1CPU.  100GB Free Bandwidth, 500 Minutes Free Pipeline/Month, Free PostgreSQL, Docker Builds, Up to 2 Custom Domains with Free TLS. 






Koyeb

 https://www.koyeb.com/

1x Web Service, 1x Postgres, 5x custom domains, 100GB/month, 







Videos

 



References


  • Zeabur template: https://zeabur.com/templates/441Y8R


No comments:

Post a Comment