Skip to content

Commit b111ec6

Browse files
authored
updated with slim build (#694)
1 parent 9622f12 commit b111ec6

File tree

19 files changed

+170
-154
lines changed

19 files changed

+170
-154
lines changed

.github/workflows/pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
uses: docker/build-push-action@v6
105105
with:
106106
context: .
107-
file: ./_docker/Dockerfile
107+
file: ./_docker/Dockerfile.slim
108108
push: false # Do not push the image for now
109109
tags: ${{ steps.meta.outputs.tags }}
110110
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/release_dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
5757
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
5858
platforms: linux/amd64,linux/arm64
59-
file: ./_docker/Dockerfile
59+
file: ./_docker/Dockerfile.slim
6060
push: true
6161
tags: ${{ steps.modify-json.outputs.cleaned_tag }}
6262
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/release_docker.yaml

Lines changed: 0 additions & 125 deletions
This file was deleted.

.github/workflows/tag.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,70 @@ jobs:
9696
push: true
9797
tags: ${{ steps.modify-json.outputs.cleaned_tag }}
9898
labels: ${{ steps.meta.outputs.labels }}
99+
100+
push_slim_release_to_registry:
101+
name: Push slim release
102+
runs-on: ubuntu-latest
103+
steps:
104+
- name: Checkout
105+
uses: actions/checkout@v4
106+
- name: Set up QEMU
107+
uses: docker/[email protected]
108+
- name: Set up Docker Buildx
109+
uses: docker/[email protected]
110+
- name: Login to Docker Hub
111+
uses: docker/login-action@v3
112+
with:
113+
username: ${{ secrets.DOCKERHUB_USERNAME }}
114+
password: ${{ secrets.DOCKERHUB_TOKEN }}
115+
- name: Login to GitHub Container Registry
116+
uses: docker/login-action@v3
117+
with:
118+
registry: ghcr.io
119+
username: ${{github.actor}}
120+
password: ${{ secrets.PAT }}
121+
- name: Extract metadata (tags, labels) for Docker and GHCR
122+
id: meta
123+
uses: docker/metadata-action@v5
124+
with:
125+
images: |
126+
gtstef/filebrowser
127+
ghcr.io/gtsteffaniak/filebrowser
128+
- name: Modify tags (strip 'v' and add 'beta'/'stable' if needed)
129+
id: modify-json
130+
run: |
131+
JSON='${{ steps.meta.outputs.json }}'
132+
MODIFIED_JSON=$(echo "$JSON" | jq '
133+
.tags |= map(sub(":v"; ":")) |
134+
if any(.tags[]; test("beta")) then
135+
.tags += [
136+
"gtstef/filebrowser:beta-slim",
137+
"ghcr.io/gtsteffaniak/filebrowser:beta-slim",
138+
"gtstef/filebrowser:slim",
139+
"ghcr.io/gtsteffaniak/filebrowser:slim"
140+
]
141+
else . end |
142+
if any(.tags[]; test("stable")) then
143+
.tags += [
144+
"gtstef/filebrowser:stable-slim",
145+
"ghcr.io/gtsteffaniak/filebrowser:stable-slim",
146+
"gtstef/filebrowser:slim",
147+
"ghcr.io/gtsteffaniak/filebrowser:slim"
148+
]
149+
else . end
150+
')
151+
TAGS_CSV=$(echo "$MODIFIED_JSON" | jq -r '.tags | join(",")')
152+
echo "$TAGS_CSV" > modified_tags.txt # Optional debug output
153+
echo "cleaned_tag=$TAGS_CSV" >> $GITHUB_OUTPUT
154+
- name: Build and push
155+
uses: docker/build-push-action@v6
156+
with:
157+
context: .
158+
build-args: |
159+
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
160+
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
161+
platforms: linux/amd64,linux/arm64,linux/arm/v7
162+
file: ./_docker/Dockerfile.slim
163+
push: true
164+
tags: ${{ steps.modify-json.outputs.cleaned_tag }}
165+
labels: ${{ steps.meta.outputs.labels }}

CHANGELOG.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,32 @@ All notable changes to this project will be documented in this file. For commit
44

55
## v0.7.6-beta
66

7+
NOTE: if using docker arm32 image, you will need to switch to the slim images. The regular docker images are much larger now and support generating office previews out of the box without any only office running. However, they don't support arm32. Also, be aware the docker images are much larger now (600MB I believe) because of the office document preview support -- if thats not something you care about you can switch to the slim images.
8+
79
**New Features**:
8-
- pdf previews always enabled for docker images (no office integration needed)
10+
- native document preview generation enabled for certain document types on the regular docker image (no office integration needed)
11+
- supported native document preview types:
12+
- ".pdf", // PDF
13+
- ".xps", // XPS
14+
- ".epub", // EPUB
15+
- ".mobi", // MOBI
16+
- ".fb2", // FB2
17+
- ".cbz", // CBZ
18+
- ".svg", // SVG
19+
- ".txt", // TXT
20+
- ".doc", // DOC
21+
- ".docx", // DOCX
22+
- ".ppt", // PPT
23+
- ".pptx", // PPTX
24+
- ".xls", // excel xls
25+
- ".xlsx", // exel XLSX
26+
- ".hwp", // HWP
27+
- ".hwp", // HWPX
928
- proxy logout redirectUrl support via `auth.methods.proxy.logoutRedirectUrl` https://github.com/gtsteffaniak/filebrowser/issues/684
1029

1130
**Notes**:
1231
- image loading placeholders added and remain if image can't be loaded.
32+
- no more arm32 support on main image -- use a `slim` tagged image.
1333

1434
**BugFixes**:
1535
- onlyoffice and other cache issues https://github.com/gtsteffaniak/filebrowser/issues/686

_docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ FROM alpine:latest
2222
COPY --from=ffmpeg [ "/ffmpeg", "/ffprobe", "/usr/local/bin/" ]
2323
# requirements to enable pdf support
2424
RUN apk add --no-cache libffi mupdf && \
25-
find / -name "libmupdf.so*" -exec sh -c 'mv "$0" "$(dirname "$0")/libmupdf.so"' {} \;
25+
find / -name "libmupdf.so*" -type f -exec mv {} /usr/lib/libmupdf.so \;
2626

2727
ENV FILEBROWSER_FFMPEG_PATH="/usr/local/bin/"
2828
ENV FILEBROWSER_NO_EMBEDED="true"

_docker/Dockerfile.armv7 renamed to _docker/Dockerfile.slim

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ WORKDIR /app
55
COPY ./backend ./
66
#RUN swag init --output swagger/docs
77
RUN ln -s swagger /usr/local/go/src/
8-
RUN go build -tags pdf -ldflags="-w -s \
8+
RUN go build -ldflags="-w -s \
99
-X 'github.com/gtsteffaniak/filebrowser/backend/common/version.Version=${VERSION}' \
1010
-X 'github.com/gtsteffaniak/filebrowser/backend/common/version.CommitSHA=${REVISION}'" \
1111
-o filebrowser .
@@ -36,10 +36,6 @@ RUN apk add --no-cache curl xz && \
3636
apk del curl xz && \
3737
rm -rf /var/cache/apk/*
3838

39-
# requirements to enable pdf support
40-
RUN apk add --no-cache libffi mupdf && \
41-
find / -name "libmupdf.so*" -exec sh -c 'mv "$0" "$(dirname "$0")/libmupdf.so"' {} \;
42-
4339
ENV FILEBROWSER_FFMPEG_PATH="/usr/local/bin/"
4440
ENV FILEBROWSER_NO_EMBEDED="true"
4541
ENV PATH="$PATH:/home/filebrowser"

backend/common/settings/structs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Settings struct {
2121
}
2222

2323
type Server struct {
24-
NumImageProcessors int `json:"numImageProcessors"` // number of concurrent image processing jobs used to create previews, default is 4,
24+
NumImageProcessors int `json:"numImageProcessors"` // number of concurrent image processing jobs used to create previews, default is number of cpu cores available.
2525
Socket string `json:"socket"` // socket to listen on
2626
TLSKey string `json:"tlsKey"` // path to TLS key
2727
TLSCert string `json:"tlsCert"` // path to TLS cert

backend/indexing/iteminfo/conditions.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@ var AllFiletypeOptions = []string{
2020
"text",
2121
}
2222

23+
var PdfConvertable = []string{
24+
".pdf", // PDF
25+
".xps", // XPS
26+
".epub", // EPUB
27+
".mobi", // MOBI
28+
".fb2", // FB2
29+
".cbz", // CBZ
30+
".svg", // SVG
31+
".txt", // TXT
32+
".doc", // DOC
33+
".docx", // DOCX
34+
".ppt", // PPT
35+
".pptx", // PPTX
36+
".xls", // XLS
37+
".xlsx", // XLSX
38+
".hwp", // HWP
39+
".hwp", // HWPX
40+
}
41+
2342
// Known bundle-style extensions that are technically directories but treated as files
2443
var BundleExtensions = []string{
2544
".app", // macOS application bundle
@@ -355,3 +374,16 @@ func hasBundleExtension(name string) bool {
355374
}
356375
return false
357376
}
377+
378+
func HasDocConvertableExtension(name string) bool {
379+
if !settings.Config.Server.PdfAvailable {
380+
return false
381+
}
382+
ext := strings.ToLower(filepath.Ext(name))
383+
for _, e := range PdfConvertable {
384+
if ext == e {
385+
return true
386+
}
387+
}
388+
return false
389+
}

backend/preview/pdf.go renamed to backend/preview/doc.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ import (
1212
"github.com/gen2brain/go-fitz"
1313
)
1414

15-
func pdfEnabled() bool {
15+
func docEnabled() bool {
1616
// This function checks if the PDF support is enabled.
1717
// In a real implementation, this might check a build tag or configuration.
1818
return true
1919
}
2020

21-
func (s *Service) GenerateImageFromPDF(pdfPath string, pageNumber int) ([]byte, error) {
21+
func (s *Service) GenerateImageFromDoc(docPath string, pageNumber int) ([]byte, error) {
2222
if err := s.acquire(context.Background()); err != nil {
2323
return nil, err
2424
}
2525
defer s.release()
26-
doc, err := fitz.New(pdfPath)
26+
doc, err := fitz.New(docPath)
2727
if err != nil {
2828
return nil, fmt.Errorf("failed to open PDF: %w", err)
2929
}
3030
defer doc.Close()
3131

32-
// Get the image from the PDF page
32+
// Get the image from the doc page
3333
img, err := doc.Image(pageNumber) // Assuming page numbers are 0-indexed as per go-fitz common usage
3434
if err != nil {
3535
return nil, fmt.Errorf("failed to get image from page %d: %w", pageNumber, err)

0 commit comments

Comments
 (0)