|
25 | 25 |
|
26 | 26 | ## 部署 |
27 | 27 |
|
28 | | -### Docker(推荐) |
| 28 | +### Docker Hub 镜像(推荐) |
29 | 29 |
|
30 | | -**docker compose(推荐)** |
| 30 | +镜像地址:`docker.io/charyeahowo/nyaovo-random-image-api:latest` |
| 31 | + |
| 32 | +每次 push 到 `main` 分支会通过 GitHub Actions 自动构建并推送。 |
| 33 | + |
| 34 | +<details> |
| 35 | +<summary><b>docker compose 部署(点击展开)</b></summary> |
31 | 36 |
|
32 | 37 | ```bash |
33 | | -git clone https://github.com/user/nyaovo-random-image-api.git |
34 | | -cd nyaovo-random-image-api |
| 38 | +# 下载配置文件 |
| 39 | +curl -O https://raw.githubusercontent.com/charyeahowo/nyaovo-random-image-api/main/docker-compose.yml |
35 | 40 |
|
36 | | -# 修改环境变量 |
37 | | -cp .env.example .env |
38 | | -# 编辑 .env,至少修改 ADMIN_PASSWORD 和 SESSION_SECRET |
| 41 | +# 编辑 docker-compose.yml,修改 ADMIN_PASSWORD 和 SESSION_SECRET |
39 | 42 |
|
40 | | -docker compose up -d --build |
| 43 | +# 启动 |
| 44 | +docker compose up -d |
41 | 45 | ``` |
42 | 46 |
|
43 | 47 | 访问 `http://localhost:3400/image`,后台 `http://localhost:3400/image/admin`。 |
44 | 48 |
|
45 | | -**docker run** |
| 49 | +</details> |
46 | 50 |
|
47 | | -```bash |
48 | | -docker build -t nyaovo-random-image-api . |
| 51 | +<details> |
| 52 | +<summary><b>docker run 部署(点击展开)</b></summary> |
49 | 53 |
|
| 54 | +```bash |
50 | 55 | docker run -d \ |
51 | 56 | --name nyaovo \ |
52 | 57 | -p 3400:3000 \ |
53 | 58 | -v ./images:/app/public/images \ |
54 | 59 | -e ADMIN_PASSWORD=your-password \ |
55 | 60 | -e SESSION_SECRET=your-secret \ |
56 | 61 | -e PUBLIC_BASE_URL=http://localhost:3400 \ |
57 | | - nyaovo-random-image-api |
| 62 | + --restart unless-stopped \ |
| 63 | + charyeahowo/nyaovo-random-image-api:latest |
58 | 64 | ``` |
59 | 65 |
|
60 | 66 | > 挂载的 `images` 目录需要写权限,不要加 `:ro`。 |
61 | 67 |
|
62 | | -**1Panel 部署** |
| 68 | +</details> |
| 69 | + |
| 70 | +<details> |
| 71 | +<summary><b>本地构建部署(点击展开)</b></summary> |
| 72 | + |
| 73 | +```bash |
| 74 | +git clone https://github.com/charyeahowo/nyaovo-random-image-api.git |
| 75 | +cd nyaovo-random-image-api |
| 76 | + |
| 77 | +cp .env.example .env |
| 78 | +# 编辑 .env,至少修改 ADMIN_PASSWORD 和 SESSION_SECRET |
| 79 | + |
| 80 | +docker compose up -d --build |
| 81 | +``` |
| 82 | + |
| 83 | +如需使用本地构建而非远程镜像,将 `docker-compose.yml` 中的 `image` 行替换为: |
| 84 | + |
| 85 | +```yaml |
| 86 | +build: |
| 87 | + context: . |
| 88 | + dockerfile: Dockerfile |
| 89 | +``` |
| 90 | +
|
| 91 | +</details> |
| 92 | +
|
| 93 | +<details> |
| 94 | +<summary><b>1Panel 部署(点击展开)</b></summary> |
63 | 95 |
|
64 | 96 | 1. 新建 Docker Compose 编排,上传项目或 Git 拉取 |
65 | | -2. 使用项目自带 `docker-compose.yml`,修改环境变量 |
| 97 | +2. 使用项目自带 `docker-compose.yml`,创建 `.env` 文件填写环境变量 |
66 | 98 | 3. 启动后在 OpenResty / Nginx 配置反向代理绑定域名 |
67 | 99 |
|
| 100 | +</details> |
| 101 | + |
68 | 102 | ### 本地运行 |
69 | 103 |
|
70 | 104 | ```bash |
|
0 commit comments