From 3c99b38db7cd15ce1bc6b4409ca31675bf0ff3ea Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Fri, 13 Dec 2024 21:40:53 -0700 Subject: [PATCH] ci: Support for arm64 docker builds --- .github/workflows/release.yml | 9 ++++++++- Cargo.lock | 11 +++++++++++ Cargo.toml | 1 + Dockerfile | 6 +++--- Dockerfile.arm64 | 27 +++++++++++++++++++++++++++ README.md | 9 ++++++++- 6 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 Dockerfile.arm64 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1537cf1..35a0034 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -317,7 +317,14 @@ jobs: - name: Push to Docker Hub uses: docker/build-push-action@v5 with: - tags: darkalex17/managarr:latest, darkalex17/managarr:${{ env.version }} + tags: darkalex17/managarr:latest, darkalex17/managarr:x86_64, darkalex17/managarr:x86_64-${{ env.version }} + push: true + + - name: Push to Docker Hub + uses: docker/build-push-action@v5 + with: + file: Dockerfile.arm64 + tags: darkalex17/managarr:arm64, darkalex17/managarr:arm64-${{ env.version }} push: true publish-crate: diff --git a/Cargo.lock b/Cargo.lock index 94bcfc1..f5bad2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1441,6 +1441,7 @@ dependencies = [ "managarr-tree-widget", "mockall", "mockito", + "openssl", "paste", "pretty_assertions", "ratatui", @@ -1673,6 +1674,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "300.4.0+3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a709e02f2b4aca747929cca5ed248880847c650233cf8b8cdc48f40aaf4898a6" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.104" @@ -1681,6 +1691,7 @@ checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] diff --git a/Cargo.toml b/Cargo.toml index 82e13d4..59612d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,6 +53,7 @@ indicatif = "0.17.9" derive_setters = "0.1.6" deunicode = "1.6.0" paste = "1.0.15" +openssl = { version = "0.10.68", features = ["vendored"] } [dev-dependencies] assert_cmd = "2.0.16" diff --git a/Dockerfile b/Dockerfile index 87b7851..8a9455d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM clux/muslrust:stable AS builder +FROM messense/rust-musl-cross:x86_64-musl AS builder WORKDIR /usr/src # Download and compile Rust dependencies in an empty project and cache as a separate Docker layer @@ -6,7 +6,7 @@ RUN USER=root cargo new --bin managarr-temp WORKDIR /usr/src/managarr-temp COPY Cargo.* . -RUN cargo build --release --target x86_64-unknown-linux-musl +RUN cargo build --release # remove src from empty project RUN rm -r src COPY src ./src @@ -15,7 +15,7 @@ RUN rm ./target/x86_64-unknown-linux-musl/release/deps/managarr* RUN --mount=type=cache,target=/volume/target \ --mount=type=cache,target=/root/.cargo/registry \ - cargo build --release --target x86_64-unknown-linux-musl --bin managarr + cargo build --release --bin managarr RUN mv target/x86_64-unknown-linux-musl/release/managarr . FROM debian:stable-slim diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 new file mode 100644 index 0000000..efe68f3 --- /dev/null +++ b/Dockerfile.arm64 @@ -0,0 +1,27 @@ +FROM messense/rust-musl-cross:armv7-musleabihf AS builder +WORKDIR /usr/src + +# Download and compile Rust dependencies in an empty project and cache as a separate Docker layer +RUN USER=root cargo new --bin managarr-temp +RUN apt update && apt install -y libssl-dev pkg-config + +WORKDIR /usr/src/managarr-temp +COPY Cargo.* . +RUN cargo build --release +# remove src from empty project +RUN rm -r src +COPY src ./src +# remove previous deps +RUN rm ./target/armv7-unknown-linux-musleabihf/release/deps/managarr* + +RUN --mount=type=cache,target=/volume/target \ + --mount=type=cache,target=/root/.cargo/registry \ + cargo build --release --bin managarr +RUN mv target/armv7-unknown-linux-musleabihf/release/managarr . + +FROM debian:stable-slim + +# Copy the compiled binary from the builder container +COPY --from=builder --chown=nonroot:nonroot /usr/src/managarr-temp/managarr /usr/local/bin + +ENTRYPOINT [ "/usr/local/bin/managarr" ] diff --git a/README.md b/README.md index 4e9b064..66e3f27 100644 --- a/README.md +++ b/README.md @@ -49,13 +49,20 @@ cargo install --locked managarr ### Docker Run Managarr as a docker container by mounting your `config.yml` file to `/root/.config/managarr/config.yml`. For example: ```shell -docker run --rm -it -v ~/.config/managarr/config.yml:/root/.config/managarr/config.yml darkalex17/managarr +docker run --rm -it -v /home/aclarke/.config/managarr/config.yml:/root/.config/managarr/config.yml darkalex17/managarr:latest +``` + +For ARM64 users, you can use the `arm64` tag: +```shell +docker run --rm -it -v /home/aclarke/.config/managarr/config.yml:/root/.config/managarr/config.yml darkalex17/managarr:arm64 ``` You can also clone this repo and run `make docker` to build a docker image locally and run it using the above command. Please note that you will need to create and popular your configuration file first before starting the container. Otherwise, the container will fail to start. +**Note:** If you run into errors using relative file paths when mounting the volume with the configuration file, try using an absolute path. + ### Manual Binaries are available on the [releases](https://github.com/Dark-Alex-17/managarr/releases) page for the following platforms: