File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -80,11 +80,22 @@ mkBlog 是一个轻量级的个人博客系统,支持 Markdown 文章、文章
8080
8181** 数据库 Docker 部署:**
8282
83+ 自行解决 MySQL 和 Postgres 的需求。默认采用的 SQLite3 不需要额外部署数据库。
84+
8385``` bash
84- cd docker
85- docker-compose up -d
86+ # 自动拉取,注意配置网络
87+ docker pull mkitsdts/mkblog:latest
88+ docker run -d --name mkblog -p 4801:4801 -v /etc/mkblog:/app/data mkitsdts/mkblog:latest
8689```
8790
91+ ``` bash
92+ # 手动构建(比较耗时,建议优先用上面)
93+ docker build -f docker/Dockerfile -t mkblog:latest .
94+ docker run -d --name mkblog -p 4801:4801 -v /etc/mkblog:/app/data mkblog:latest
95+ ```
96+
97+ 通过docker部署后,配置文件会被写入到 /etc/mkblog目录下。
98+
8899## 访问地址
89100
90101前后端统一地址,所以没有跨域问题
Original file line number Diff line number Diff line change 1- #
2- FROM golang:tip -alpine AS backend
1+ #
2+ FROM golang:1.24 -alpine AS backend
33WORKDIR /app
44
55RUN sed -i 's#https\? ://dl-cdn.alpinelinux.org/alpine#https://mirrors.tuna.tsinghua.edu.cn/alpine#g' /etc/apk/repositories
@@ -10,7 +10,11 @@ COPY . .
1010RUN go env -w GOPROXY=https://goproxy.io,direct
1111RUN go mod tidy
1212
13- RUN CGO_ENABLED=1 GOOS=linux go build -o /app/main .
13+ RUN CGO_ENABLED=1 \
14+ GOOS=linux \
15+ GOGC=20 \
16+ GOMAXPROCS=2 \
17+ go build -ldflags="-s -w" -o /app/main .
1418
1519#
1620FROM alpine:3.22
@@ -19,9 +23,7 @@ WORKDIR /app
1923COPY --from=backend /app/main .
2024
2125COPY --from=backend /app/static ./static
22- # 复制配置文件
23- COPY config.yaml ./config.yaml
2426
25- EXPOSE 8080 6060
27+ EXPOSE 4801 6060
2628
2729CMD ["./main" ]
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments