joesturge / lazymc-docker-proxy

Put your Minecraft containers to rest when idle.
GNU General Public License v3.0
24 stars 2 forks source link

arm64 support & question #122

Open otomay opened 2 weeks ago

otomay commented 2 weeks ago

Hey! Could you support arm64 in the pre-built images, please?

running with latest build: exec /usr/local/bin/lazymc-docker-proxy: exec format error

I builded locally on my arm64 device, but it didn't work, probably because of the cargo build targeting x86_64.

306.1   = note: cc: error: unrecognized command-line option '-m64'
306.1           
306.1 
306.2 warning: `lazymc-docker-proxy` (bin "lazymc-docker-proxy") generated 1 warning
306.2 error: could not compile `lazymc-docker-proxy` (bin "lazymc-docker-proxy") due to 1 previous error; 1 warning emitted
------

 4 warnings found (use docker --debug to expand):
 - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 6)
 - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 18)
 - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 30)
 - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 41)
Dockerfile:38
--------------------
  36 |     COPY Cargo.toml Cargo.lock ./
  37 |     COPY src ./src
  38 | >>> RUN cargo build --target x86_64-unknown-linux-musl --release --locked
  39 |     
  40 |     # health init
--------------------
ERROR: failed to solve: process "/bin/sh -c cargo build --target x86_64-unknown-linux-musl --release --locked" did not complete successfully: exit code: 101

and my question:

  # you should mount the minecraft server dir under /server, using read only.
  - data:/server:ro

can I just point to the same volume /data of "mc" service? or should I point to specific server folder?

thanks!

joesturge commented 3 days ago

Hi @otomay thanks for opening the issue, yep we can make this support arm, to your question, you can mount the same volume in multiple containers, that how it is done in the example, and it would work if you do ro in one place and rw in another

otomay commented 3 days ago

Thank you! I tried to contribute by forking, but got stuck. I edited the Dockerfile to adjust the cargo build to identify the arch, but I got rust errors when running and I know nothing about rust :/

IDK if help, but I'll share what have I done:

ARG LAZYMC_VERSION=0.2.11
ARG LAZYMC_LEGACY_VERSION=0.2.10

FROM busybox:1.37.0-uclibc as downloader

ARG TARGETARCH
ARG LAZYMC_VERSION
ENV LAZYMC_VERSION=$LAZYMC_VERSION
RUN if [ "$TARGETARCH" = "amd64" ]; then \
        wget https://github.com/timvisee/lazymc/releases/download/v${LAZYMC_VERSION}/lazymc-v${LAZYMC_VERSION}-linux-x64 -O /lazymc; \
    elif [ "$TARGETARCH" = "arm64" ]; then \
        wget https://github.com/timvisee/lazymc/releases/download/v${LAZYMC_VERSION}/lazymc-v${LAZYMC_VERSION}-linux-aarch64 -O /lazymc; \
    elif [ "$TARGETARCH" = "armv7" ]; then \
        wget https://github.com/timvisee/lazymc/releases/download/v${LAZYMC_VERSION}/lazymc-v${LAZYMC_VERSION}-linux-armv7 -O /lazymc; \
    fi

RUN chmod +x /lazymc

ARG LAZYMC_LEGACY_VERSION
ENV LAZYMC_LEGACY_VERSION=$LAZYMC_LEGACY_VERSION
RUN if [ "$TARGETARCH" = "amd64" ]; then \
        wget https://github.com/timvisee/lazymc/releases/download/v${LAZYMC_LEGACY_VERSION}/lazymc-v${LAZYMC_LEGACY_VERSION}-linux-x64 -O /lazymc-legacy; \
    elif [ "$TARGETARCH" = "arm64" ]; then \
        wget https://github.com/timvisee/lazymc/releases/download/v${LAZYMC_LEGACY_VERSION}/lazymc-v${LAZYMC_LEGACY_VERSION}-linux-aarch64 -O /lazymc-legacy; \
    elif [ "$TARGETARCH" = "armv7" ]; then \
        wget https://github.com/timvisee/lazymc/releases/download/v${LAZYMC_LEGACY_VERSION}/lazymc-v${LAZYMC_LEGACY_VERSION}-linux-armv7 -O /lazymc-legacy; \
    fi

RUN chmod +x /lazymc-legacy

# build this app
FROM rust:1.81 as app-builder
RUN rustup target add x86_64-unknown-linux-musl aarch64-unknown-linux-musl
RUN apt update && apt install -y musl-tools musl-dev
RUN update-ca-certificates
RUN apt-get update && apt-get install -y pkg-config libssl-dev
WORKDIR /usr/src/lazymc-docker-proxy
COPY Cargo.toml Cargo.lock ./
COPY src ./src
ARG TARGETARCH
RUN if [ "$TARGETARCH" = "amd64" ]; then \
        cargo build --target x86_64-unknown-linux-musl --release --locked; \
    elif [ "$TARGETARCH" = "arm64" ]; then \
        cargo build --target aarch64-unknown-linux-musl --release --locked; \
    fi

FROM busybox:1.37.0-uclibc as health-init
RUN mkdir -p /app && echo "STARTING" > /app/health

FROM busybox:1.37.0-uclibc

ARG TARGETARCH
ARG LAZYMC_VERSION
ENV LAZYMC_VERSION=$LAZYMC_VERSION
ARG LAZYMC_LEGACY_VERSION
ENV LAZYMC_LEGACY_VERSION=$LAZYMC_LEGACY_VERSION

COPY --from=downloader /lazymc /usr/local/bin/lazymc
COPY --from=downloader /lazymc-legacy /usr/local/bin/lazymc-legacy
COPY --from=app-builder /usr/src/lazymc-docker-proxy/target/${TARGETARCH/arm64/aarch64}-unknown-linux-musl/release/lazymc-docker-proxy /usr/local/bin/lazymc-docker-proxy
COPY --from=health-init /app/health /app/health

WORKDIR /app

HEALTHCHECK --start-period=1m --interval=5s --retries=24 CMD ["lazymc", "--health"]

ENTRYPOINT ["lazymc-docker-proxy"]

I just downloaded the pre-build binaries instead of building like you to speed things up on my testings. But maybe it can be worth to use like that? idk

and the the logs from lazymc container (where I got stucked):

 INFO  lazymc-docker-proxy::entrypoint > Ensuring all server containers are stopped...
 INFO  lazymc-docker-proxy::entrypoint > Starting lazymc process for group: mc...
thread 'main' panicked at src/entrypoint/mod.rs:35:14:
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace