Compare commits

..
3 Commits
Author SHA1 Message Date
XingfenD 8bcef95dd4 Merge branch 'feat/docker-support' 2026-08-27 15:35:04 +08:00
XingfenD 3171866344 chore: gitignore local .env file 2026-08-27 15:32:57 +08:00
XingfenD 1f8529badc feat: add Docker deployment support
Add Dockerfile, docker-compose.yml, .dockerignore, .env.example, Makefile docker targets, and README/CHANGELOG docs.
2026-08-27 15:32:47 +08:00
8 changed files with 100 additions and 1 deletions
+10
View File
@@ -0,0 +1,10 @@
.git
.gitignore
*.md
docs
tests
workspace
yDropbox
docker-compose.yml
.env
.env.example
+3
View File
@@ -0,0 +1,3 @@
# 访问令牌(必填)。请将下方示例替换为高强度随机字符串。
# Access token (required). Replace the example below with a strong random string.
YDROPBOX_TOKEN=change-me-to-a-strong-random-token
+3
View File
@@ -21,3 +21,6 @@ Thumbs.db
# Superpowers workspace
.superpowers/
# local env with secrets
.env
+19
View File
@@ -0,0 +1,19 @@
# syntax=docker/dockerfile:1
FROM golang:1.25-alpine AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /out/yDropbox ./cmd/ydropbox
FROM alpine:3.20
RUN adduser -D -u 10001 -s /sbin/nologin ydropbox \
&& apk add --no-cache ca-certificates tzdata
WORKDIR /app
COPY --from=build /out/yDropbox /app/yDropbox
USER ydropbox
VOLUME /app/workspace
EXPOSE 8999
ENTRYPOINT ["/app/yDropbox"]
CMD ["--addr", "0.0.0.0:8999", "--workspace", "/app/workspace"]
+10 -1
View File
@@ -1,7 +1,7 @@
BINARY := yDropbox
PKG := ./cmd/ydropbox
.PHONY: build test run clean vet
.PHONY: build test run clean vet docker docker-up docker-down
build:
CGO_ENABLED=0 go build -o $(BINARY) $(PKG)
@@ -17,3 +17,12 @@ vet:
clean:
rm -f $(BINARY)
docker:
docker build -t ydropbox .
docker-up:
docker compose up -d --build
docker-down:
docker compose down
+15
View File
@@ -0,0 +1,15 @@
services:
ydropbox:
build: .
image: yoresee/yDropbox:latest
container_name: ydropbox
restart: unless-stopped
ports:
- "8999:8999"
environment:
YDROPBOX_TOKEN: ${YDROPBOX_TOKEN:?set YDROPBOX_TOKEN in .env}
volumes:
- ydropbox-data:/app/workspace
volumes:
ydropbox-data:
+13
View File
@@ -6,6 +6,19 @@ All notable changes to this template should be documented in this file.
The format loosely follows Keep a Changelog and can be adapted to the team's habits.
本文档参考了 Keep a Changelog 的思路,也可以根据团队习惯调整。
## [0.1.0] - 2026-08-27
### Added / 新增
- Added Docker deployment support: `Dockerfile`, `.dockerignore`, `docker-compose.yml` and `.env.example`.
- 新增 Docker 部署支持:`Dockerfile`、`.dockerignore`、`docker-compose.yml` 与 `.env.example`。
- Added `make docker` / `make docker-up` / `make docker-down` convenience targets to the Makefile.
- 在 Makefile 中新增 `make docker` / `make docker-up` / `make docker-down` 便捷命令。
- Documented Docker deployment in `docs/README.md`.
- 在 `docs/README.md` 中补充了 Docker 部署说明。
## [0.0.1] - 2026-04-28
### Added / 新增
+27
View File
@@ -49,6 +49,33 @@ make vet # 静态检查 (go vet ./...)
make clean # 删除二进制文件
```
## Docker 部署
项目提供了 `Dockerfile` 与 `docker-compose.yml`,将编译产物打包为单一镜像(前端资源已通过 `go:embed` 内嵌,SQLite 为纯 Go 实现,镜像无外部依赖)。
### 使用 Docker Compose(推荐)
```bash
cp .env.example .env
# 编辑 .env,设置 YDROPBOX_TOKEN 为一个高强度随机字符串
docker compose up -d --build
```
服务启动后监听 `8999` 端口,文件与数据库持久化在名为 `ydropbox-data` 的卷中。
### 仅使用 Docker
```bash
docker build -t ydropbox .
docker run -d --name ydropbox \
-p 8999:8999 \
-e YDROPBOX_TOKEN=YOUR_SECRET_TOKEN \
-v "$(pwd)/workspace:/app/workspace" \
ydropbox
```
> 注意:必须通过 `-e YDROPBOX_TOKEN=...` 或 `--token` 提供访问令牌,否则服务启动会失败(与本地运行一致)。
## 配置
| 参数 / 环境变量 | 说明 | 默认值 |