Skip to content

Commit

Permalink
Make docker hub multi-arch image
Browse files Browse the repository at this point in the history
  • Loading branch information
vinser committed Dec 31, 2024
1 parent 8f90686 commit 2fcf730
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/.vscode/
/apptree/
/cmd/flibgolite/books/
/cmd/flibgolite/config/
/cmd/flibgolite/dbdata/
/cmd/flibgolite/logs/
/bin/
/config/
/dbdata/
/logs/
Expand Down
26 changes: 8 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
42 changes: 33 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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,)
Expand Down Expand Up @@ -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
# 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
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
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.

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`
Expand Down
26 changes: 26 additions & 0 deletions docker_run.sh
Original file line number Diff line number Diff line change
@@ -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
41 changes: 0 additions & 41 deletions ops/docker-config.yml

This file was deleted.

0 comments on commit 2fcf730

Please sign in to comment.