Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
# Docker builds read only the plain JAR, Maven runtime dependencies and config.
*
**
!Dockerfile
!docker/
!docker/Dockerfile.base
!docker/kkfileview-base/
!docker/kkfileview-base/fonts/
!docker/kkfileview-base/fonts/**
!server/
!server/target/
!server/target/eap-fileview-*.jar
!server/target/dependency/
!server/target/dependency/*.jar
!server/src/
!server/src/main/
!server/src/main/config/
!server/src/main/config/application.properties
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
EAP_FILEVIEW_VERSION=3.0.3
EAP_FILEVIEW_PORT=18012
EAP_FILEVIEW_IMAGE=ghcr.io/eaopen/eap-fileview:3.0.2
EAP_FILEVIEW_BASE_IMAGE=ghcr.io/eaopen/eap-fileview-base:java21-sb41-r2
EAP_FILEVIEW_BUILD_IMAGE=eap-fileview:dev
KK_BASE_URL=http://localhost:18012/fileview/
KK_TRUST_HOST=files.example.org
KK_NOT_TRUST_HOST=default
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/base-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ jobs:
cache: maven
- name: Resolve stable dependency tree
run: mvn -B -pl server -am -DskipTests clean package
- uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
Expand All @@ -26,7 +29,8 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile.base
file: Dockerfile
target: runtime
push: true
platforms: linux/amd64,linux/arm64
tags: ghcr.io/eaopen/eap-fileview-base:java21-sb41-r2
Expand Down
42 changes: 12 additions & 30 deletions .github/workflows/container-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,16 @@ permissions:
jobs:
smoke:
runs-on: ubuntu-latest
env:
KK_BASE_URL: http://localhost:18012/fileview/
KK_TRUST_HOST: localhost
steps:
- name: Start published Java 21 and LibreOffice image
run: |
set -euo pipefail
docker pull ghcr.io/eaopen/eap-fileview:3.0.2
docker run -d --name fileview-smoke \
--publish 127.0.0.1:18012:8012 \
--env KK_CONTEXT_PATH=/fileview \
--env KK_SERVER_PORT=8012 \
--env KK_BASE_URL=http://localhost:18012/fileview/ \
--env KK_TRUST_HOST=localhost \
--env KK_FILE_DIR=/tmp/fileview-smoke \
ghcr.io/eaopen/eap-fileview:3.0.2
trap 'docker logs --tail 75 fileview-smoke || true; docker rm -f fileview-smoke || true' EXIT
ready=false
for i in $(seq 1 90); do
if ! docker inspect -f '{{.State.Running}}' fileview-smoke | grep -q true; then
echo 'Container exited before becoming healthy'
exit 1
fi
code="$(curl --silent --output /tmp/health.out --write-out '%{http_code}' \
http://127.0.0.1:18012/fileview/actuator/health || true)"
if [ "$code" = "200" ]; then
grep -q '"status":"UP"' /tmp/health.out
ready=true
break
fi
sleep 4
done
[ "$ready" = true ] || { echo 'Viewer health endpoint never became UP'; exit 1; }
echo 'Viewer container healthy; Java/LibreOffice startup successful'
- uses: actions/checkout@v4
- name: Start published image with the deployment configuration
run: docker compose up -d --pull always --wait --wait-timeout 180
- name: Verify health through the published port
run: curl -fsS http://127.0.0.1:18012/fileview/actuator/health | jq -e '.status == "UP"'
- if: failure()
run: docker compose logs --tail 75
- if: always()
run: docker compose down --volumes
7 changes: 6 additions & 1 deletion .github/workflows/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
fi
- name: Package only plain JAR
run: mvn -B -pl server -am -DskipTests clean package
- uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
Expand All @@ -43,5 +46,7 @@ jobs:
build-args: |
APP_VERSION=${{ steps.version.outputs.value }}
tags: ghcr.io/eaopen/eap-fileview:${{ steps.version.outputs.value }}
cache-from: type=gha,scope=fileview-app
cache-from: |
type=gha,scope=fileview-app
type=gha,scope=fileview-stable-base
cache-to: type=gha,mode=max,scope=fileview-app
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Active coding guidance for this repository. The original kkFileView agent instru
- `server/src/main/resources/web/`: FreeMarker viewer templates.
- `server/src/main/resources/static/`: viewer JS/CSS/assets.
- `server/src/main/config/`: application and test runtime properties.
- `Dockerfile`: thin app layer; `docker/Dockerfile.base`: stable Java/LibreOffice/dependencies layer.
- `Dockerfile`: shared `runtime` stage for Java/LibreOffice/dependencies and a thin `application` stage.
- `compose.yaml` and `compose.build.yaml`: pull-only and local-build Compose configurations.
- `.github/workflows/`: active GitHub CI, CNB/Central Maven publishing and image workflows.
- `doc/kkfileview/`: preserved upstream README, original AGENTS, CI/E2E notes. These are **not current runbooks**.
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
# Self-contained runtime: avoid dependency on a separately published GHCR base package.
FROM ubuntu:24.04
FROM ubuntu:24.04 AS runtime
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
Expand All @@ -15,6 +15,8 @@ WORKDIR /opt/eap-fileview
# Copy Maven runtime jars resolved by the release build.
COPY server/target/dependency/ ./lib/
ENV LANG=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8

FROM runtime AS application
ARG APP_VERSION=3.0.3
COPY server/target/eap-fileview-${APP_VERSION}.jar ./app.jar
COPY server/src/main/config/application.properties ./config/application.properties
Expand Down
8 changes: 5 additions & 3 deletions README.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ flowchart LR
```bash
cp .env.example .env
# 修改 .env 中的 KK_BASE_URL / KK_TRUST_HOST 等配置
docker compose up -d
docker compose up -d --wait --wait-timeout 180
```

升级前记录当前 `EAP_FILEVIEW_IMAGE`,将其改为目标版本标签或摘要,执行 `docker compose pull` 后重跑启动命令。需要回退时恢复原镜像引用并重跑这两步。Compose 等待健康检查通过,预览缓存保存在命名卷中。

自行构建开发镜像时,先执行 Maven clean package;Dockerfile 自包含运行环境,不需要预先构建基础镜像:

```bash
docker compose -f compose.yaml -f compose.build.yaml build
docker compose -f compose.yaml -f compose.build.yaml up -d
mvn -B -pl server -am -DskipTests clean package
docker compose -f compose.yaml -f compose.build.yaml up -d --build --wait --wait-timeout 180
```

**当前应用镜像自包含** Java 21、LibreOffice、字体、运行依赖和普通 JAR;单独的基础镜像属于可选产物,并非当前 Dockerfile 的前置依赖。默认监听容器内 8012,Compose 映射本机 `127.0.0.1:18012`,上下文路径 `/fileview`。镜像是否已公开可拉取以 [GitHub Actions 发布记录](https://github.com/eaopen/eap-fileview/actions) 为准。
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,16 @@ Using the last **published** 3.0.2 image (Boot 4.1.1); 3.0.3 is not yet released
```bash
cp .env.example .env
# Configure KK_BASE_URL and KK_TRUST_HOST inside .env
docker compose up -d
docker compose up -d --wait --wait-timeout 180
```

Before upgrading, record the current `EAP_FILEVIEW_IMAGE`. Set it to the target version tag or digest, run `docker compose pull`, then repeat the startup command. To roll back, restore the previous image reference and repeat both commands. Compose waits for the health check and keeps the preview cache in its named volume.

To build the unreleased version locally, first run Maven clean package. The Dockerfile is self-contained:

```bash
docker compose -f compose.yaml -f compose.build.yaml build
docker compose -f compose.yaml -f compose.build.yaml up -d
mvn -B -pl server -am -DskipTests clean package
docker compose -f compose.yaml -f compose.build.yaml up -d --build --wait --wait-timeout 180
```

The current application Dockerfile is self-contained: Java 21, LibreOffice, fonts, runtime dependencies and the ordinary JAR. The separately published base image is optional and not used by this Dockerfile. Compose defaults to `127.0.0.1:18012` and the `/fileview` context path. Verify actual [image publication status](https://github.com/eaopen/eap-fileview/actions) before attempting a pull.
Expand Down
1 change: 1 addition & 0 deletions compose.build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
services:
eap-fileview:
image: ${EAP_FILEVIEW_BUILD_IMAGE:-eap-fileview:dev}
pull_policy: build
build:
context: .
dockerfile: Dockerfile
Expand Down
14 changes: 14 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ services:
KK_OFFICE_PREVIEW_TYPE: pdf
volumes:
- fileview-preview-cache:/opt/eap-fileview/file
healthcheck:
test:
- CMD
- bash
- -ec
- |
exec 3<>/dev/tcp/127.0.0.1/8012
printf 'GET /fileview/actuator/health HTTP/1.0\r\nHost: localhost\r\nConnection: close\r\n\r\n' >&3
read -r proto status rest <&3
test "$$status" = 200
interval: 15s
timeout: 5s
retries: 4
start_period: 60s
restart: unless-stopped

volumes:
Expand Down
6 changes: 3 additions & 3 deletions doc/EXTENSION_RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Ubuntu 24.04 + OpenJDK 21 + LibreOffice + 开源中文字体 + **Maven 已解析
该镜像只在 Java/LibreOffice/字体/依赖变化时才考虑手动构建;**当前 Dockerfile 自包含,不需要预先构建此基础镜像**。旧的 r1 镜像标签不能覆盖。

```bash
mvn -B -pl server -am -DskipTests package
docker build -f docker/Dockerfile.base \
mvn -B -pl server -am -DskipTests clean package
docker build --target runtime \
-t ghcr.io/eaopen/eap-fileview-base:java21-sb41-r2 .
```

Expand All @@ -58,7 +58,7 @@ docker compose --env-file .env.example -f compose.yaml -f compose.build.yaml bui
# 正常部署(镜像已经发布后):
cp .env.example .env
# 修改来源主机白名单和公网访问地址
docker compose up -d
docker compose up -d --wait --wait-timeout 180
```

GHCR 最终镜像工作流:`.github/workflows/images.yml`,采用 `revision` 作为应用标签;下一次正式版本的 Git tag 应为 `v3.0.3`。
Expand Down
17 changes: 0 additions & 17 deletions docker/Dockerfile.base

This file was deleted.

2 changes: 1 addition & 1 deletion docker/kkfileview-base/README.cn.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# 稳定镜像字体资源

本目录只保留额外字体资源。新版本以仓库 docker/Dockerfile.base 构建基础镜像,不是从本目录独立构建。参考 ../../doc/EXTENSION_RELEASE.md。
本目录只保留额外字体资源。新版本以仓库 `docker build --target runtime .` 构建基础镜像,不是从本目录独立构建。参考 ../../doc/EXTENSION_RELEASE.md。
2 changes: 1 addition & 1 deletion docker/kkfileview-base/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Stable runtime fonts only

This folder contains optional extra fonts. The supported build is now docker/Dockerfile.base at the repository root. See ../../doc/EXTENSION_RELEASE.md.
This folder contains optional extra fonts. The supported build is now `docker build --target runtime .` at the repository root. See ../../doc/EXTENSION_RELEASE.md.
Loading