diff --git a/.gitignore b/.gitignore index c39b6a5..1cf0172 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ /.vscode/ -/apptree/ /cmd/flibgolite/books/ /cmd/flibgolite/config/ /cmd/flibgolite/dbdata/ /cmd/flibgolite/logs/ +/bin/ /config/ /dbdata/ /logs/ diff --git a/Dockerfile b/Dockerfile index 75d74ce..0b7af56 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,16 @@ -FROM golang:1.18.3 as builder +# syntax=docker/dockerfile:1 -# build flibgolite -COPY . /flibgolite -WORKDIR /flibgolite -RUN go build ./cmd/flibgolite - -FROM alpine:3.16.0 -COPY --from=builder /flibgolite/flibgolite /flibgolite/flibgolite - -# run flibgolite with musl instead of glibc -RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 +# build dp +FROM --platform=$BUILDPLATFORM scratch +# FROM gcr.io/distroless/static-debian12 +# FROM --platform=$BUILDPLATFORM alpine -# configure service and directories -RUN mkdir -p /flibgolite/config /var/flibgolite -COPY ops/docker-config.yml /flibgolite/config/config.yml +ARG TARGETOS TARGETARCH TARGETVARIANT +COPY ./bin/flibgolite-$TARGETOS-$TARGETARCH${TARGETVARIANT:+-${TARGETVARIANT#v}} /flibgolite/flibgolite # expose ports EXPOSE 8085 -# probes -HEALTHCHECK --interval=30s --timeout=3s \ - CMD wget --no-verbose --tries=1 --spider http://localhost:8085/opds || exit 1 - +WORKDIR /flibgolite # run command ENTRYPOINT ["/flibgolite/flibgolite"] diff --git a/Makefile b/Makefile index defb6b4..2f8debc 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,8 @@ # variable definitions -APP := flibgolite +CMD_MAIN := $(shell find cmd/ -name main.go) +APP := $(patsubst cmd/%/main.go,%,$(CMD_MAIN)) VERSION := $(shell git describe --tags --always --dirty) GOVERSION := $(shell go env GOVERSION) @@ -11,19 +12,17 @@ BUILDTIME := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") HOSTOS := $(shell go env GOHOSTOS) HOSTARCH := $(shell go env GOHOSTARCH) -CMD_MAIN := $(shell find cmd/$(APP) -name main.go) -OUTPUT := $(patsubst cmd/%/main.go,%,$(CMD_MAIN)) - build_cmd = \ + CGO_ENABLED=0 \ GOOS=$(1) \ GOARCH=$(2) \ $(if $(3),GOARM=$(3)) \ - go build -ldflags " \ + go build -ldflags "-s \ -X 'main.version=$(VERSION)' \ -X 'main.buildTime=$(BUILDTIME)' \ -X 'main.goversion=$(GOVERSION)' \ -X 'main.target=$(1)-$(2)$(if $(3),-$(3))'" \ - -o $(OUTPUT)-$(1)-$(2)$(if $(3),-$(3))$(if $(findstring windows,$(1)),.exe) \ + -o bin/$(APP)-$(1)-$(2)$(if $(3),-$(3))$(if $(findstring windows,$(1)),.exe) \ $(abspath $(dir $(CMD_MAIN))) all: build @@ -34,10 +33,10 @@ build: # Cross builds -xbuild: linux darwin windows +xbuild: linux darwin windows freebsd # Linux builds ======================== -linux: build_linux_armV6 build_linux_armV7 build_linux_arm64 build_linux_amd64 +linux: build_linux_amd64 build_linux_armV6 build_linux_armV7 build_linux_arm64 build_linux_amd64: $(call build_cmd,linux,amd64,) @@ -66,4 +65,29 @@ windows: build_windows_amd64 build_windows_amd64: $(call build_cmd,windows,amd64,) -.PHONY: all check build xbuild linux darwin windows build_linux_arm build_linux_arm64 build_linux_amd64 build_darwin_amd64 build_darwin_arm64 build_windows_amd64 \ No newline at end of file +# FreeBSD builds ======================== +freebsd: build_freebsd_amd64 build_freebsd_armV6 build_freebsd_armV7 build_freebsd_arm64 + +build_freebsd_amd64: + $(call build_cmd,freebsd,amd64,) + +build_freebsd_armV6: + $(call build_cmd,freebsd,arm,6) + +build_freebsd_armV7: + $(call build_cmd,freebsd,arm,7) + +build_freebsd_arm64: + $(call build_cmd,freebsd,arm64,) + +docker_xbuild: + docker build --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 --tag vinser/$(APP):$(VERSION) . + docker image tag vinser/$(APP):$(VERSION) vinser/$(APP):latest + +docker_push: + docker push vinser/$(APP):$(VERSION) + +run_container: + $(shell ./docker_run.sh) + +.PHONY: all build xbuild linux darwin windows build_linux_arm build_linux_arm64 build_linux_amd64 build_darwin_amd64 build_darwin_arm64 build_windows_amd64 \ No newline at end of file diff --git a/README.md b/README.md index 5de8470..36e59c1 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,21 @@ FLibGoLite - Just enough for free OPDS === -__FLibGoLite__ is an easy-to-install and resource-friendly OPDS service written in pure Go. +__FLibGoLite__ is an easy-to-install, fast and resource-friendly OPDS service. __Detailed multilingual guides are available [here](https://vinser.github.io/flibgolite-docs/)__ -### CURRENT STABLE RELEASE v2.2.2 +### CURRENT STABLE RELEASE v2.2.3 __FLibGoLite__ main features: -- Support for FB2 (separate files and zip archives), EPUB files. -- Ability to convert FB2 to EPUB when downloading a book to a reader. -- Multiplatform: Windows, MacOS, Linux. Easy to assemble for NAS under FreeBSD -- Self-sufficient - does not require the installation of any additional libraries or applications. +- Works with books in FB2 (separate files and zip archives) and EPUB formats +- Ability to convert FB2 format to EPUB when loading a book into the reader +- Multiplatform: Linux, Windows, MacOS, FreeBSD +- Self-sufficiency - does not require installation of additional libraries or applications +- Can be launched as a system service or in a Docker container, as well as from the command line +- Fast inexing and keep persistent data in SQLite database +- High speed of processing new arrivals and saving the catalog in the SQLite database +- Fast and responsive OPDS service with a simple localization +- Well documented #### Briefly how to use FLibGoLite. @@ -18,14 +23,11 @@ You need: 1. PC, NAS or server with Windows, MacOS or Linux operating system. 2. A reader (device or application) that can work with OPDS catalogs and supports FB2 or EPUB book formats. +FLibGoLite has been tested and works with mobile applications for reading books `PocketBook Reader`, `FBReader`, `Librera Reader`, `Cool Reader`, as well as desktop applications `Foliate` and `Thorium Reader`. You can use any other applications or devices that can read the listed book formats and work with OPDS catalogs. -FLibGoLite has been tested and works with mobile applications for reading books `PocketBook Reader`, `FBReader`, `Librera Reader`, `Cool Reader`, -as well as desktop applications `Foliate` and `Thorium Reader`. -You can use any other applications or devices that can read the listed book formats and work with OPDS catalogs. +Follow these [guide](https://vinser.github.io/flibgolite-docs/en/docs/user-guide/) to install FLibGoLite on your PC. -Follow these [guide](https://vinser.github.io/flibgolite-docs/en/docs/user-guide/) to install FLibGoLite on your PC and -put your books in FB2 format (zip-archives or separate files) or EPUB in the `books/stock` folder. -The service processes them and enters the books details into the catalog. +Put your books in FB2 format (zip-archives or separate files) or EPUB in the `books/stock` folder. The service processes them and enters the books details into the catalog. Next, configure the reader(s) to work with the OPDS directory `http://server:8085/opds`, where `server` is the name of your PC or the IP address of the PC type `192.168.0.10` diff --git a/docker_run.sh b/docker_run.sh new file mode 100755 index 0000000..fa17d62 --- /dev/null +++ b/docker_run.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# the script runs flibgolite docker container + +# run this script from the root of the app folder + +# put your books in the "books" folder +books_dir=$(pwd)/books +mkdir -p $books_dir + +# here you can view logs +logs_dir=$(pwd)/logs +mkdir -p $logs_dir + +# here is your books index database. Back up it if you want +dbdata_dir=$(pwd)/dbdata +mkdir -p $dbdata_dir + + +docker run -d \ +--name=flibgolite \ +-p 8085:8085 \ +--mount type=bind,source=$books_dir,target=/flibgolite/books \ +--mount type=bind,source=$dbdata_dir,target=/flibgolite/dbdata \ +--mount type=bind,source=$logs_dir,target=/flibgolite/logs \ +vinser/flibgolite:latest \ No newline at end of file diff --git a/ops/docker-config.yml b/ops/docker-config.yml deleted file mode 100644 index 2cf57dc..0000000 --- a/ops/docker-config.yml +++ /dev/null @@ -1,41 +0,0 @@ -library: - # Selfexplained folders - STOCK: "/var/flibgolite/books/stock" - NEW: "/var/flibgolite/books/new" - TRASH: "/var/flibgolite/books/trash" - -genres: - TREE_FILE: "/var/flibgolite/config/genres.xml" - # Alternative genres tree can be used (Russian only, sorry) - # TREE_FILE: "config/alt_genres.xml" - -database: - DSN: "/var/flibgolite/dbdata/flibgolite.db" - # Delay before start each new acquisitions processing - POLL_DELAY: 30 - # Maximum simultaneous new aquisitios processing threads - MAX_SCAN_THREADS: 1 - -logs: - # Logs are here - OPDS: "/dev/stdout" - SCAN: "/dev/stdout" - LEVEL: "W" - -opds: - # OPDS-server port so opds can be found at http://:8085/opds - PORT: 8085 - # OPDS-server title that is displayed in a book reader - TITLE: "FLib Go Go Go!!!" - # OPDS feeds entries page size - PAGE_SIZE: 30 - -locales: - # Locales folder. You can add your own locale file there like en.yml, ru.yml, uk.yml - DIR: "/var/flibgolite/config/locales" - # Default english locale for opds feeds (bookreaders opds menu tree) can be changed to: - # "uk" for Ukrainian, - # "ru" for Russian - DEFAULT: "en" - # Accept only these languages publications. Add others if needed please. - ACCEPTED: "en, ru, uk"