diff --git a/build.md b/build.md new file mode 100644 index 0000000..b68eb43 --- /dev/null +++ b/build.md @@ -0,0 +1,44 @@ +## Compilation + +Install `Go >= 1.16` and `GCC`. Get the source code: + + git clone https://github.com/nkanaev/yarr.git + +Then run one of the corresponding commands: + + # 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 + + # host-specific cli version (no gui) + make build_default # -> _output/yarr + + # ... or start a dev server locally + make serve # starts a server at http://localhost:7070 + + # ... or build a docker image + docker build -t yarr . + +## ARM compilation + +The instructions below are to cross-compile *yarr* to `Linux/ARM*`. + +Build: + + docker build -t yarr.arm -f dockerfile.arm . + +Test: + + # inside host + docker run -it --rm yarr.arm + + # then, inside container + cd /root/out + qemu-aarch64 -L /usr/aarch64-linux-gnu/ yarr.arm64 + +Extract files from images: + + CID=$(docker create yarr.arm) + docker cp -a "$CID:/root/out" . + docker rm "$CID" diff --git a/dockerfile.arm b/dockerfile.arm new file mode 100644 index 0000000..7ed43a8 --- /dev/null +++ b/dockerfile.arm @@ -0,0 +1,33 @@ +FROM ubuntu:20.04 + +# Install GCC +RUN apt update +RUN apt install -y \ + wget build-essential \ + gcc-aarch64-linux-gnu \ + binutils-aarch64-linux-gnu binutils-aarch64-linux-gnu-dbg +RUN env DEBIAN_FRONTEND=noninteractive \ + apt install -y qemu-user qemu-user-static + +# Install Golang +RUN wget --quiet https://go.dev/dl/go1.18.2.linux-amd64.tar.gz && \ + rm -rf /usr/local/go && \ + tar -C /usr/local -xzf go1.18.2.linux-amd64.tar.gz +ENV PATH=$PATH:/usr/local/go/bin + +# Copy source code +WORKDIR /root/src +RUN mkdir /root/out +COPY . . + +# Build ARM64 +RUN env \ + CC=aarch64-linux-gnu-gcc \ + CGO_ENABLED=1 \ + GOOS=linux GOARCH=arm64 \ + go build \ + -tags "sqlite_foreign_keys release linux" \ + -ldflags="-s -w" \ + -o /root/out/yarr.arm64 src/main.go + +CMD ["/bin/bash"] diff --git a/readme.md b/readme.md index 11e3106..6111449 100644 --- a/readme.md +++ b/readme.md @@ -45,25 +45,7 @@ and pasting the content: Categories=Internet; For self-hosting, see `yarr -h` for auth, tls & server configuration flags. - -## build - -Install `Go >= 1.16` and `gcc`. Get the source code: - - git clone https://github.com/nkanaev/yarr.git - -Then run one of the corresponding commands: - - # 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 - - # ... or start a dev server locally - make serve # starts a server at http://localhost:7070 - - # ... or build a docker image - docker build -t yarr . +For building from source code, see [doc/build.md](doc/build.md) ## credits diff --git a/yarr.arm64 b/yarr.arm64 new file mode 100755 index 0000000..9d72442 Binary files /dev/null and b/yarr.arm64 differ