Skip to content

Commit 86090fe

Browse files
committed
support docker
1 parent d28e41c commit 86090fe

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM golang:1.20-alpine as builder
2+
3+
RUN apk add --no-cache gcc musl-dev linux-headers git
4+
5+
WORKDIR /build
6+
7+
COPY go.mod go.mod
8+
COPY go.sum go.sum
9+
RUN go mod download
10+
11+
COPY . ./
12+
13+
RUN go build -trimpath -ldflags="-w -s" -o /build/zeronet2web .
14+
15+
FROM alpine:3
16+
17+
WORKDIR /app
18+
RUN apk update --no-cache && apk upgrade && apk add --no-cache ca-certificates
19+
20+
COPY templates /app/templates
21+
COPY --from=builder /build/zeronet2web /app/zeronet2web
22+
23+
24+
ENTRYPOINT ["./zeronet2web"]

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,12 @@ Output the content of zeronet to the web, because search engines can only index
2020
```
2121
.\zeronet2web.exe -dir "F:/soft/ZeroNet-win/data/" -host "https://zeronet.ipfsscan/"
2222
```
23+
24+
### docker run
25+
26+
docker run -it -v /mnt/f/soft/zeroNet-win/data/:/zeronet-data/ -v ./db/:/app/db/ -p 20236:20236 chenjia404/zeronet2web /zero
27+
net-data/ -dir "/zeronet-data/" -host "https://zeronet.ipfsscan/"
28+
29+
Note that please change `/mnt/f/soft/zeroNet-win/data/` to the data directory of your zeronet.
30+
31+
./db/ is the blog index data storage directory.

README.zh-CN.md

+10
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,13 @@ go build -trimpath -ldflags="-w -s"
1717
```
1818
.\zeronet2web.exe -dir "F:/soft/ZeroNet-win/data/" -host "https://zeronet.ipfsscan/"
1919
```
20+
21+
22+
### docker 运行
23+
24+
docker run -it -v /mnt/f/soft/zeroNet-win/data/:/zeronet-data/ -v ./db/:/app/db/ -p 20236:20236 chenjia404/zeronet2web /zero
25+
net-data/ -dir "/zeronet-data/" -host "https://zeronet.ipfsscan/"
26+
27+
注意请把`/mnt/f/soft/zeroNet-win/data/` 修改成你的zeronet的data目录。
28+
29+
./db/ 是博客索引数据保存目录。

main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ var ZeroNetDataPath = ""
163163
var ProxyHost = ""
164164

165165
func main() {
166-
db, _ := gorm.Open(sqlite.Open("zeronet.blogs.db"), &gorm.Config{
166+
os.Mkdir("./db/", os.FileMode(0777))
167+
db, _ := gorm.Open(sqlite.Open("db/zeronet.blogs.db"), &gorm.Config{
167168
DisableForeignKeyConstraintWhenMigrating: true,
168169
})
169170
db.AutoMigrate(&models.Blog{})

0 commit comments

Comments
 (0)