使用镜像

jkjoy/typecho:latest

latest 内置testore插件

nginx + php7.4 + sqlite + typecho 1.2.1

准备工作

  • 注册FLY.IO
    用以部署typecho

安装flyctl

Install flyctl
以WINDOWS为例

1
pwsh -Command "iwr https://fly.io/install.ps1 -useb | iex"

其他系统请参照官方

新建APP

初始化

1
flyctl launch

按照提示选择会生成一个FLY.TOML文件

编辑FLY.TOML

添加以下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# fly.toml app configuration file generated for gotos on 2023-08-12T19:36:14+08:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "typecho"
primary_region = "hkg"

[experimental]
vm = true

[build]
image = "jkjoy/typecho:latest"

[env]
PHP_MAX_EXECUTION_TIME = 600
PHP_TZ = "Asia/Shanghai"

[[mounts]]
source = "typecho_data"
destination = "/usr/share/nginx/html/usr/"

[http_service]
internal_port = 80
force_https = true
auto_stop_machines = false
auto_start_machines = true
min_machines_running = 1
processes = ["app"]

添加持久卷

1
flyctl volumes create typecho_data --region hkg --size 1

部署

1
flyctl deploy

演示地址

https://avnvu.fly.dev/

进阶

fly.toml的文件同目录下执行

1
fly ssh console

此时会自动连接到此 APP 容器的 SSH 服务
由于我所使用的镜像是由Ubuntu构建,可以使用 apt 命令

此处列出 typecho 所在目录/usr/share/nginx/html/
此为 nginx 默认的网站目录

github上找到自己需要的主题或者插件可以使用

1
git clone

来下载到网站的相应目录下,即可

当然你也可以打包好所有的插件和模板为 zip 格式
使用wget的方式在容器内解压缩
使用unzip命令即可

为了不让 app 重启后丢失数据 我建议映射/usr/share/nginx/html/下的usr目录.