[5 Mins Docker] Deploy A Light Weight, Fast Navigation Site - Flame (Docker Run & Fly.io) - NETSEC

Latest

Learning, Sharing, Creating

Cybersecurity Memo

Saturday, March 4, 2023

[5 Mins Docker] Deploy A Light Weight, Fast Navigation Site - Flame (Docker Run & Fly.io)

Based on Github project page, Flame is self-hosted startpage for your server. Its design is inspired (heavily) by SUI. Flame is very easy to setup and use. With built-in editors, it allows you to setup your very own application hub in no time - no file editing necessary.

There is similar projected , Flare, which is more like a Chinese version of Flame. It does provide quite a few enhancements on features and speed, but one thing it is missing from Flare is the authentication, although Flare seems much nicer and faster. 

In this post, I am going to show you how to get both projects up and running in the cloud, and more specifically, how to run in in Fly.io platform. 

Introduction

Flame: https://github.com/pawelmalak/flame

Flame is self-hosted startpage for your server. Easily manage your apps and bookmarks with built-in editors.



Flare: https://github.com/soulteary/docker-flare

Flare  Lightweight, high performance and fast self-hosted navigation pages, resource utilization rate is <1% CPU, MEM <30 M, Docker Image < 10M




Flare project was inspired from another similar project Flame in Github: https://github.com/pawelmalak/flame

Feature list:


  • 📝 Create, update, delete your applications and bookmarks directly from the app using built-in GUI editors
  • 📌 Pin your favourite items to the homescreen for quick and easy access
  • 🔍 Integrated search bar with local filtering, 11 web search providers and ability to add your own
  • 🔑 Authentication system to protect your settings, apps and bookmarks
  • 🔨 Dozens of options to customize Flame interface to your needs, including support for custom CSS, 15 built-in color themes and custom theme builder
  • ☀️ Weather widget with current temperature, cloud coverage and animated weather status
  • 🐳 Docker integration to automatically pick and add apps based on their labels


Self Hosted Docker Installation Pre-requirements

Free resources you might need to complete this docker project:


Pre-installed services:

  • Docker, 
    • apt update
    • apt install docker.io
    • apt install docker-compose
    • apt upgrade docker.io
    • mkdir /root/data/docker_data/<docker_name>
  • Docker-Compose (Using Ubuntu OS for the commands)
    • Docker-compose down
    • Optional command : use following command to backup your Docker data. You might need to change your folder name based on your docker configuraiton
      • cp -r /root/data/docker_data/<docker_name> /root/data/docker_data_backup/<docker_name>
    • docker-compose pull
    • docker-compose up -d
    • docker image prune
  • Portainer (Optional)
    • docker volume create portainer_data
    • docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
  • Install some applications: apt install wget curl sudo vim git (Optional)
  • aapanel with Nginx (Optional)
  • Nginx Proxy Manager (Optional)
  • Install screen (Optional)
    • Install screen (Depends on the Linux Distribution if it came pre installed or not) : yum install screen
    • Initiate a Screen : screen or  screen -S <screen name> <command to execute>
    • Detach from the screen : "CTRL+A,D" not "CTRL+A+D"
    • List all the screen currently working : screen -ls
    • Reattach to a screen : screen  -r  <session number> or screen -r <screen name>
    • Kill specific screen: screen -X -S <screen name> quit
    • Kill all screens : pkill screen



Docker Run & Docker Compose


Flame:


docker run -p 5005:5005 -v /path/to/data:/app/data -e PASSWORD=flame_password pawelmalak/flame

Docker-compose.yml

version: '3.6'

services:
  flare:
    image: soulteary/flare
    restart: always
    # 默认无需添加任何参数,如有特殊需求
    # 可阅读文档 https://github.com/soulteary/docker-flare/blob/main/docs/advanced-startup.md
    command: flare
    # 启用账号登陆模式
    # command: flare --nologin=0
    # environment:
      # 如需开启用户登陆模式,需要先设置 `nologin` 启动参数为 `0`
      # 如开启 `nologin`,未设置 FLARE_USER,则默认用户为 `flare`
      # - FLARE_USER=flare
      # 指定你自己的账号密码,如未设置 `FLARE_USER`,则会默认生成密码并展示在应用启动日志中
      # - FLARE_PASS=your_password
      # 是否开启“使用向导”,访问 `/guide`
      # - FLARE_GUIDE=1
    ports:
      - 5005:5005
    volumes:
      - ./app:/app

docker-compose up -d


Flare:


docker run --rm -it -p 5005:5005 -v `pwd`/app:/app soulteary/flare


Docker-compose.yml

version: '3.6'

services:
  flame:
    image: pawelmalak/flame
    container_name: flame
    volumes:
      - /path/to/host/data:/app/data
      - /var/run/docker.sock:/var/run/docker.sock # optional but required for Docker integration
    ports:
      - 5005:5005
    secrets:
      - password # optional but required for (1)
    environment:
      - PASSWORD=flame_password
      - PASSWORD_FILE=/run/secrets/password # optional but required for (1)
    restart: unless-stopped

# optional but required for Docker secrets (1)
secrets:
  password:
    file: /path/to/secrets/password
docker-compose up -d


Deploy to Fly.io



https://fly.io/docs/getting-started/
https://fly.io/docs/hands-on/

1 Install flyctl if you are using Windows machine. For other OS, check installation guide:

  • powershell -Command "iwr https://fly.io/install.ps1 -useb | iex"


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

  • fly launch



3 Notepad fly.toml


4 Create a new 1GB volume disk for persistent data.

  • fly volumes create speedtest_data --size 1

5 fly launch again



All commands and outputs:

PS C:\Users\netsec> fly auth login
Opening https://fly.io/app/auth/cli/c41ccd9759be02c0a0dd2d2a096d58 ...
Waiting for session... Done
successfully logged in as [email protected]
PS C:\Users\netsec>
PS C:\Users\netsec>
PS C:\Users\netsec> flyctl launch
Creating app in C:\Users\netsec
Scanning source code
Could not find a Dockerfile, nor detect a runtime or framework from source code. Continuing with a blank app.
? Choose an app name (leave blank to generate one):
? Choose an app name (leave blank to generate one):
? Select Organization: 51Sec (51sec)
Some regions require a paid plan (fra, maa).
See https://fly.io/plans to set up a plan.
? Choose a region for deployment: Toronto, Canada (yyz)
Created app broken-brook-3157 in organization 51sec
Admin URL: https://fly.io/apps/broken-brook-3157
Hostname: broken-brook-3157.fly.dev
Wrote config file fly.toml
PS C:\Users\netsec> notepad fly.toml
PS C:\Users\netsec> fly volumes create flame_data --size 1
Some regions require a paid plan (fra, maa).
See https://fly.io/plans to set up a plan.
? Select region: Toronto, Canada (yyz)
        ID: vol_g67340kkkk2vydxw
      Name: flare_data
       App: broken-brook-3157
    Region: yyz
      Zone: acc6
   Size GB: 1
 Encrypted: true
Created at: 27 Feb 23 03:18 UTC
PS C:\Users\netsec> notepad fly.toml
PS C:\Users\netsec> fly launch
An existing fly.toml file was found for app broken-brook-3157
App is not running, deploy...
==> Building image
Searching for image 'soulteary/flare:0.3.1' remotely...
image found: img_0lq747o9nd5v6x35
==> Creating release
--> release v2 created
--> You can detach the terminal anytime without stopping the deployment
==> Monitoring deployment
Logs: https://fly.io/apps/broken-brook-3157/monitoring
 1 desired, 1 placed, 1 healthy, 0 unhealthy [health checks: 1 total, 1 passing]
--> v0 deployed successfully
PS C:\Users\netsec>


Flame:

Use notepad to edit fly.toml file, which was generated by "flyctl launch" command. 

# fly.toml file generated for flame on 2023-03-04T16:22:46-05:00
app = "51flame"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[build]
  image = "pawelmalak/flame"

[env]
  PASSWORD = "Flame1234!"
[mounts]
  source="flame_data"
  destination="/app/data"

[experimental]
  auto_rollback = true
[[services]]
  http_checks = []
  internal_port = 5005
  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"


Flare:

Use notepad to edit fly.toml file, which was generated by "flyctl launch" command. 

# fly.toml file generated for broken-brook-3157 on 2023-02-26T19:11:40-08:00
app = "51flare"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[build]
  image = "soulteary/flare:0.3.1"
[env]
[mounts]
  source="flare_data"
  destination="/app"
[experimental]
  auto_rollback = true
[[services]]
  http_checks = []
  internal_port = 5005
  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"



Usage

Flame:

/settings

/applications

/bookmarks

/


Authenticated user has access to:

  • all apps
  • all categories
  • all bookmarks
  • all editors
  • all settings

Guest user has access to:

  • all apps set to public (homescreen - only pinned, apps - all public apps)
  • all categories set to public (homescreen - only pinned, bookmarks - all public categories)
  • all bookmarks set to public (homescreen/bookmarks - only if parent category is set to public)
  • Theme and App sections of settings

Flare:


/editor



/config

/guide


/help


Test Performance using Google Chrome Lighthouse:




Flame

 



PS C:\Users\netsec> fly auth login
Opening https://fly.io/app/auth/cli/c41ccd9759be02c0a0dd2d2a096d58 ...
Waiting for session... Done
successfully logged in as [email protected]
PS C:\Users\netsec>
PS C:\Users\netsec>
PS C:\Users\netsec> flyctl launch
Creating app in C:\Users\netsec
Scanning source code
Could not find a Dockerfile, nor detect a runtime or framework from source code. Continuing with a blank app.
? Choose an app name (leave blank to generate one):
? Choose an app name (leave blank to generate one):
? Select Organization: 51Sec (51sec)
Some regions require a paid plan (fra, maa).
See https://fly.io/plans to set up a plan.
? Choose a region for deployment: Toronto, Canada (yyz)
Created app broken-brook-3157 in organization 51sec
Admin URL: https://fly.io/apps/broken-brook-3157
Hostname: broken-brook-3157.fly.dev
Wrote config file fly.toml
PS C:\Users\netsec> notepad fly.toml
PS C:\Users\netsec> fly volumes create flame_data --size 1

PS C:\Users\netsec> notepad fly.toml
PS C:\Users\netsec> fly launch
An existing fly.toml file was found for app broken-brook-3157
App is not running, deploy...
==> Building image
Searching for image 'soulteary/flare:0.3.1' remotely...
image found: img_0lq747o9nd5v6x35
==> Creating release
--> release v2 created
--> You can detach the terminal anytime without stopping the deployment
==> Monitoring deployment
Logs: https://fly.io/apps/broken-brook-3157/monitoring
 1 desired, 1 placed, 1 healthy, 0 unhealthy [health checks: 1 total, 1 passing]
--> v0 deployed successfully
PS C:\Users\netsec>



Use notepad to edit fly.toml file, which was generated by "flyctl launch" command. 

# fly.toml file generated for flare51 on 2023-02-26T20:00:01-08:00
app = "flare51"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[build]
  image = "pawelmalak/flame"
[env]
  PASSWORD = "flame"
[experimental]
  auto_rollback = true
[mounts]
  destination = "/app/data"
  source = "flame_data"
[[services]]
  http_checks = []
  internal_port = 5005
  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"




Custome Domain

Launch Web CLI:
https://fly.io/terminal

1. Download your fly.toml


2. Migrate to Apps v2

The fly migrate-to-v2 command will migrate flame to v2 of our apps platform, and roll back in case of any issues.


3. Save updated config locally

Now, you need to save the updated fly.toml locally, and commit it to your git repo. On your local machine, run:

$ fly config save -a flame



Config a certificate for your own domain:

cname is slower usually. A record will be much faster for this process.


Troubleshooting

 

In Linux or Mac environment, run the install script to install Fly.io cli:

curl -L https://fly.io/install.sh | sh

If you used curl to install flyctl, then you need to add the flyctl directory to your shell rc file. Check the output of the install script for the entries to copy and paste into the file. Now you can use the flyctl command from any directory. Or for maximum efficiency, you can use the fly command!

Else, you will have to use full path to run fly such as:
  • /root/.fly/bin/fly launch



Fly.io commands




PS C:\Users\john> fly orgs show freshrss51sec
Organization
Name      : freshrss51sec
Slug      : freshrss51sec
Type      : SHARED
Summary
You have admin permissions on this organizaton
There are 1 members associated with this organization
Organization Members
+------+----------------------+-------+
| NAME |        EMAIL         | ROLE  |
+------+----------------------+-------+
|      | [email protected] | ADMIN |
+------+----------------------+-------+
PS C:\Users\john>fly volumes destroy vol_53q80vdpk66vgzy6
Warning! Every volume is pinned to a specific physical host. You should create two or more volumes per application. Deleting this volume will leave you with 1 volume(s) for this application,? Are you sure you want to destroy this volume? Yes
Destroyed volume ID: vol_53q80vdpk66vgzy6 name: freshrss51sec_data
PS C:\Users\john>PS C:\Users\john> fly config save -a freshrss51
Wrote config file fly.toml
PS C:\Users\john> fly volumes list
ID                      STATE   NAME                    SIZE    REGION  ZONE    ENCRYPTED       ATTACHED VM     CREATED AT
vol_53q80vdpk66vgzy6    created freshrss51sec_data      1GB     yyz     5e29    true                            1 year ago
vol_1q85vg3lem8rzdxe    created freshrss51sec_data      1GB     yyz     aeee    true            e28606eb740486  10 months ago
PS C:\Users\john> 






Videos

 




No comments:

Post a Comment