update build doc & dockerfiles

This commit is contained in:
nkanaev 2025-03-21 00:38:32 +00:00
parent 572e489db6
commit a32361fab2
3 changed files with 26 additions and 20 deletions

View File

@ -1,21 +1,33 @@
## Compilation
Install `Go >= 1.17` and `GCC`. Get the source code:
Prerequisies:
* Go >= 1.18
* C Compiler (GCC / Clang / ...)
* Zig >= 0.14.0 (optional, for cross-compiling CLI versions)
* binutils (optional, for building Windows GUI version)
Get the source code:
git clone https://github.com/nkanaev/yarr.git
Then run one of the corresponding commands:
Compile:
# create an executable for the host os
make build_macos # -> _output/macos/yarr.app
make build_linux # -> _output/linux/yarr
make build_windows # -> _output/windows/yarr.exe
# create cli for the host OS/architecture
make host # out/yarr
# host-specific cli version (no gui)
make build_default # -> _output/yarr
# create GUI, works only in the target OS
make windows_amd64_gui # out/windows_amd64_gui/yarr.exe
make windows_arm64_gui # out/windows_arm64_gui/yarr.exe
make darwin_arm64_gui # out/darwin_arm64_gui/yarr.app
make darwin_amd64_gui # out/darwin_amd64_gui/yarr.app
# ... or start a dev server locally
make serve # starts a server at http://localhost:7070
# create cli, cross-compiles within any OS/architecture
make linux_amd64
make linux_arm64
make linux_armv7
make windows_amd64
make windows_arm64
# ... or build a docker image
docker build -t yarr -f etc/dockerfile .

View File

@ -3,12 +3,12 @@ RUN apk add build-base git
WORKDIR /src
COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/root/go/pkg \
make build_linux
make host
FROM alpine:latest
RUN apk add --no-cache ca-certificates && \
update-ca-certificates
COPY --from=build /src/_output/linux/yarr /usr/local/bin/yarr
COPY --from=build /src/out/yarr /usr/local/bin/yarr
EXPOSE 7070
ENTRYPOINT ["/usr/local/bin/yarr"]
CMD ["-addr", "0.0.0.0:7070", "-db", "/data/yarr.db"]

View File

@ -27,18 +27,12 @@ RUN env \
CC=aarch64-linux-gnu-gcc \
CGO_ENABLED=1 \
GOOS=linux GOARCH=arm64 \
go build \
-tags "sqlite_foreign_keys linux" \
-ldflags="-s -w" \
-o /root/out/yarr.arm64 ./cmd/yarr
make host && mv out/yarr /root/out/yarr.arm64
RUN env \
CC=arm-linux-gnueabihf-gcc \
CGO_ENABLED=1 \
GOOS=linux GOARCH=arm GOARM=7 \
go build \
-tags "sqlite_foreign_keys linux" \
-ldflags="-s -w" \
-o /root/out/yarr.arm7 ./cmd/yarr
make host && mv out/yarr /root/out/yarr.armv7
CMD ["/bin/bash"]