目录
- 官网
- 使用源码构建镜像
- k8s启动yaml参考
- 使用介绍
官网
- 官网:
http://kkfileview.keking.cn/zh-cn/index.html
- 在线文档:
http://kkfileview.keking.cn/zh-cn/docs/home.html
- 源码地址:
https://gitee.com/kekingcn/file-online-preview
- 发行版下载页面:
https://gitee.com/kekingcn/file-online-preview/releases
- 下载发行版需要加入kk开源社区,加入需要支付99元
- 下载源码,自行编译
- 快速开始:
https://gitee.com/kekingcn/file-online-preview/tree/v4.3.0/#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B
使用源码构建镜像
- 源码编译
# 下载源码
git clone https://gitee.com/kekingcn/file-online-preview
# 编译、打包
mvn clean package -Dmaven.test.skip=true
- 修改file-online-preview/Dockerfile
FROM keking/kkfileview-jdk:latest
MAINTAINER chenjh "842761733@qq.com"
ADD kkFileView-*.tar.gz /opt/
ENV KKFILEVIEW_BIN_FOLDER /opt/kkFileView-4.4.0-SNAPSHOT/bin
ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-Dspring.config.location=/opt/kkFileView-4.4.0-SNAPSHOT/config/application.properties","-jar","/opt/kkFileView-4.4.0-SNAPSHOT/bin/kkFileView-4.4.0-SNAPSHOT.jar"]
-
把file-online-preview/Dockerfile和server/target/kkFileView-*.tar.gz放到同一个目录下
-
执行构建命令
# kkFileView
IMAGE_NAME=kkfileview
IMAGE_VERSION=4.4.0-SNAPSHOT
HARBOR_URL=harbor.xxx.com:20443
IMAGE_FULL_PATH=${HARBOR_URL}/base/${IMAGE_NAME}:${IMAGE_VERSION}
docker image build --tag ${IMAGE_FULL_PATH} .
docker image push ${IMAGE_FULL_PATH}
k8s启动yaml参考
主要内容如下
apiVersion: apps/v1
kind: Deployment
metadata:
name: kkfileview
namespace: kube-public
spec:
selector:
matchLabels:
app: kkfileview
replicas: 1
template:
metadata:
labels:
app: kkfileview
spec:
imagePullSecrets:
- name: puller
containers:
- name: kkfileview
image: harbor.xxx.com/base/kkfileview:4.4.0-SNAPSHOT
imagePullPolicy: Always
env:
- name: KK_CONTEXT_PATH
value: "/preview"
- name: KK_BASE_URL
value: "https://m.ipipa.cn/preview"
ports:
- containerPort: 8012
readinessProbe:
httpGet:
path: /preview/onlinePreview
port: 8012
livenessProbe:
httpGet:
path: /preview/onlinePreview
port: 8012
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 1
---
apiVersion: v1
kind: Service
metadata:
name: kkfileview-svc
namespace: kube-public
spec:
selector:
app: kkfileview
ports:
- name: http
protocol: TCP
port: 8012
targetPort: 8012
nodePort: 18012
type: NodePort
使用介绍
- 文件地址: https://xxx.com/web/入职培训.pdf
- 把文件地址进行base64编码:
aHR0cHM6Ly94eHguY29tL3dlYi/lhaXogYzln7norq0ucGRm
- 再进行urlEncode:
aHR0cHM6Ly94eHguY29tL3dlYi%2FlhaXogYzln7norq0ucGRm
- 然后再传给预览服务:
https://xxx.com:18012/preview/onlinePreview?url=aHR0cHM6Ly94eHguY29tL3dlYi%2FlhaXogYzln7norq0ucGRm
- 在浏览器打开这个地址就可以正常预览了