add all-in-one docker image build scripts

pull/455/head
Michael Li 11 months ago
parent 35c2c14ec3
commit e8b65edff7
No known key found for this signature in database

@ -2,7 +2,8 @@
All notable changes to paopao-ce are documented in this file.
## 0.6.0+dev ([`dev`](https://github.com/rocboss/paopao-ce/tree/dev))
TODO;
### Added
- add all-in-one docker image build scripts.
## 0.5.2
### Change

@ -52,7 +52,7 @@ PaoPao主要由以下优秀的开源项目/工具构建
* [Mir](https://github.com/alimy/mir 'go-mir')
* [Buf](https://github.com/bufbuild/buf 'buf')
* [gRPC](https://github.com/grpc/grpc-go 'grpc-go')
* [Zinc](https://zinclabs.io/ 'zinc')
* [Meilisearch](https://https://www.meilisearch.com/ 'meilisearch')
#### 前端:
* [Naive UI](https://www.naiveui.com/)
@ -69,9 +69,7 @@ PaoPao主要由以下优秀的开源项目/工具构建
* Node.js (14+)
* MySQL (5.7+)
* Redis
* Zinc
> Zinc是一款轻量级全文搜索引擎可以查阅 <https://zincsearch.com/> 安装
* Meilisearch
以上环境版本为PaoPao官方的开发版本仅供参考其他版本的环境未进行充分测试
@ -221,6 +219,23 @@ PaoPao主要由以下优秀的开源项目/工具构建
docker run -d -p 8010:80 your/paopao-ce:web
```
* All-In-One:
```sh
# 构建Image
docker buildx build --build-arg USE_DIST="yes" -t your/paopao-ce:all-in-one-latest -f Dockerfile.allinone .
# 运行
docker run --name paopao-ce-allinone -d -p 8000:8008 -p 7700:7700 -v ./data/custom:/app/custom -v ./data/meili_data:/app/meili_data your/paopao-ce:all-in-one-latest
# 或者使用官方Image运行
docker run --name paopao-ce-allinone -d -p 8000:8008 -p 7700:7700 -v ./data/custom:/app/custom -v ./data/meili_data:/app/meili_data bitbus/paopao-ce:all-in-one-latest
# 或者使用官方Image运行 + 自定义config.yaml
docker run --name paopao-ce-allinone -d -p 8000:8008 -p 7700:7700 -v ./config.yaml:/app/config.yaml -v ./data/custom:/app/custom -v ./data/meili_data:/app/meili_data bitbus/paopao-ce:all-in-one-latest
```
> 注意在`config.yaml` 中`Meili.ApiKey`的值必须与容器中meili启动时设定的`MEILI_MASTER_KEY`环境变量值相同,默认为`paopao-meilisearch`. 可以在docker启动容器时通过`-e MEILI_MASTER_KEY=<custom-key>`设置该值。
### 方式三. 使用 docker-compose 运行
```sh
git clone https://github.com/rocboss/paopao-ce.git

@ -4,8 +4,8 @@ set -xe
# Create paopao user for paopao-ce
addgroup -S paopao
adduser -G paopao -H -D -g 'paopao User' paopao -h /data/paopao -s /bin/bash && usermod -p '*' paopao && passwd -u paopao
echo "export PAOPAO_CUSTOM=${PAOPAO_CUSTOM}" >> /etc/profile
adduser -G paopao -H -D -g 'paopao User' paopao -h /app -s /bin/sh && usermod -p '*' paopao && passwd -u paopao
# echo "export PAOPAO_CUSTOM=${PAOPAO_CUSTOM}" >> /etc/profile
# Final cleaning
mv /app/docker/config.yaml /app/config.yaml

@ -21,7 +21,7 @@ SmsJuhe:
Logger: # 日志通用配置
Level: debug # 日志级别 panic|fatal|error|warn|info|debug|trace
LoggerFile: # 使用File写日志
SavePath: custom/data/paopao-ce/logs
SavePath: custom/logs
FileName: app
FileExt: .log
JWT: # 鉴权加密
@ -37,7 +37,7 @@ ObjectStorage: # 对象存储通用配置
RetainInDays: 2 # 临时对象过期时间多少天
TempDir: tmp # 临时对象存放目录名
LocalOSS: # 本地文件OSS存储配置
SavePath: custom/data/paopao-ce/oss
SavePath: custom/oss
Secure: False
Bucket: paopao
Domain: 127.0.0.1:8008
@ -45,7 +45,7 @@ Database: # Database通用配置
LogLevel: error # 日志级别 silent|error|warn|info
TablePrefix: p_ # 表名前缀
Sqlite3: # Sqlite3数据库
Path: custom/data/sqlite3/paopao-ce.db
Path: custom/paopao-ce.db
Redis:
InitAddress:
- 127.0.0.1:6379

@ -0,0 +1,3 @@
#!/bin/sh
cd /app/meili_data || exit 1

@ -1,3 +1,5 @@
#!/bin/sh
# sleep 10s等待meilisearch启动完成这是笨方法暂时先凑着后面再找更靠谱的法子这里之所以要等待meili启动完成是因为paopao-ce首次启动时需要初始化一次meili的index如果初始化失败就无法在后续使用。
sleep 10
cd /app || exit 1

@ -1,4 +1,4 @@
FROM getmeili/meilisearch:v1.4 as meilisearch
FROM getmeili/meilisearch:v1.5 as meilisearch
FROM redis:7.2-alpine
ENV TZ=Asia/Shanghai
@ -8,7 +8,7 @@ RUN apk update --quiet \
ca-certificates \
libgcc \
curl \
s6
s6 \
&& update-ca-certificates
WORKDIR /app
@ -17,13 +17,14 @@ COPY ./docker ./docker
# add meilisearch and meilitool to the `/bin` so you can run it from anywhere
# and it's easy to find.
COPY --from=meilisearch /bin/meilisearch /bin/meilisearch
COPY --from-meilisearch /bin/meilitool /bin/meilitool
COPY --from=meilisearch /bin/meilitool /bin/meilitool
# To stay compatible with the older version of the container (pre v0.27.0) we're
# going to symlink the meilisearch binary in the path to `/meilisearch`
RUN ln -s /bin/meilisearch /meilisearch
ENV MEILI_HTTP_ADDR 0.0.0.0:7700
ENV MEILI_SERVER_PROVIDER docker
ENV MEILI_DB_PATH=/app/meili_data
VOLUME ["/app/meili_data"]
ENV MEILI_MASTER_KEY=paopao-meilisearch
RUN ./docker/build/finalize.sh

@ -3,5 +3,5 @@
```sh
docker build -t bitbus/paopao-ce-backend-builder:latest -f Dockerfile.backend-builder .
docker build -t bitbus/paopao-ce-backend-runner:latest -f Dockerfile.backend-runner .
docker build -t bitbus/paopao-ce-allinone-runner:latest -f Dockerfile.allinone-runner .
docker build -t bitbus/paopao-ce-allinone-runner:latest -f scripts/docker/Dockerfile.allinone-runner .
```

@ -1,7 +1,5 @@
PRAGMA foreign_keys=off;
BEGIN TRANSACTION;
ALTER TABLE p_post_content RENAME TO _p_post_content;
ALTER TABLE p_comment_content RENAME TO _p_comment_content;
@ -53,46 +51,6 @@ CREATE TABLE p_comment_reply
PRIMARY KEY ("id")
);
-- ----------------------------
-- Indexes structure for table p_post_content
-- ----------------------------
CREATE INDEX "idx_post_content_post_id"
ON "p_post_content" (
"post_id" ASC
);
CREATE INDEX "idx_post_content_user_id"
ON "p_post_content" (
"user_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_comment_reply
-- ----------------------------
CREATE INDEX "idx_comment_reply_comment_id"
ON "p_comment_reply" (
"comment_id" ASC
);
-- ----------------------------
-- Indexes structure for table p_comment_content
-- ----------------------------
CREATE INDEX "idx_comment_content_comment_id"
ON "p_comment_content" (
"comment_id" ASC
);
CREATE INDEX "idx_comment_content_sort"
ON "p_comment_content" (
"sort" ASC
);
CREATE INDEX "idx_comment_content_type"
ON "p_comment_content" (
"type" ASC
);
CREATE INDEX "idx_comment_content_user_id"
ON "p_comment_content" (
"user_id" ASC
);
INSERT INTO p_post_content (id, post_id, user_id, content, `type`, sort, created_on, modified_on, deleted_on, is_del)
SELECT id, post_id, user_id, content, `type`, sort, created_on, modified_on, deleted_on, is_del
FROM _p_post_content;
@ -112,10 +70,12 @@ DROP TABLE _p_comment_reply;
-- ----------------------------
-- Indexes structure for table p_post_content
-- ----------------------------
DROP INDEX IF EXISTS "idx_post_content_post_id";
CREATE INDEX "idx_post_content_post_id"
ON "p_post_content" (
"post_id" ASC
);
DROP INDEX IF EXISTS "idx_post_content_user_id";
CREATE INDEX "idx_post_content_user_id"
ON "p_post_content" (
"user_id" ASC
@ -124,6 +84,7 @@ ON "p_post_content" (
-- ----------------------------
-- Indexes structure for table p_comment_reply
-- ----------------------------
DROP INDEX IF EXISTS "idx_comment_reply_comment_id";
CREATE INDEX "idx_comment_reply_comment_id"
ON "p_comment_reply" (
"comment_id" ASC
@ -132,23 +93,25 @@ ON "p_comment_reply" (
-- ----------------------------
-- Indexes structure for table p_comment_content
-- ----------------------------
DROP INDEX IF EXISTS "idx_comment_content_comment_id";
CREATE INDEX "idx_comment_content_comment_id"
ON "p_comment_content" (
"comment_id" ASC
);
DROP INDEX IF EXISTS "idx_comment_content_sort";
CREATE INDEX "idx_comment_content_sort"
ON "p_comment_content" (
"sort" ASC
);
DROP INDEX IF EXISTS "idx_comment_content_type";
CREATE INDEX "idx_comment_content_type"
ON "p_comment_content" (
"type" ASC
);
DROP INDEX IF EXISTS "idx_comment_content_user_id";
CREATE INDEX "idx_comment_content_user_id"
ON "p_comment_content" (
"user_id" ASC
);
COMMIT;
PRAGMA foreign_keys=on;

Loading…
Cancel
Save