Skip to content
This repository was archived by the owner on Mar 24, 2024. It is now read-only.

Commit 0620d9e

Browse files
committed
make dockerfile multi-arch
1 parent f9b257a commit 0620d9e

2 files changed

Lines changed: 35 additions & 6 deletions

File tree

Dockerfile

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
1-
FROM rust:1.61-slim-bullseye AS auditor
1+
FROM --platform=$BUILDPLATFORM rust:1.61-slim-bullseye AS auditor
22
RUN apt-get update && \
33
apt-get install -y --no-install-recommends pkg-config=0.29.2-1 libssl-dev=1.1.1n-1+deb11u1 && \
44
USER=root cargo new --bin highlights && \
55
cargo install cargo-audit
66
COPY ["Cargo.*", "./"]
77
RUN cargo audit -D unsound -D yanked
88

9-
FROM rust:1.61-alpine3.15 AS builder
9+
FROM --platform=$BUILDPLATFORM rust:1.61-alpine3.15 AS builder
1010
RUN apk add --no-cache --update musl-dev=1.2.2-r7 && \
1111
USER=root cargo new --bin highlights
12+
13+
ARG RUSTTARGET
14+
ARG MUSLHOST
15+
ARG MUSLTARGET
16+
RUN if [[ ! -z "$RUSTTARGET" ]]; then \
17+
rustup target add $RUSTTARGET && \
18+
wget https://more.musl.cc/10.2.1/$MUSLHOST/$MUSLTARGET-cross.tgz && \
19+
tar xzf $MUSLTARGET-cross.tgz; \
20+
fi
21+
1222
WORKDIR /highlights
1323
COPY ["Cargo.toml", "Cargo.lock", "./"]
14-
RUN cargo build --release && \
15-
rm src/*.rs && \
16-
rm ./target/release/deps/highlights*
24+
RUN cargo fetch ${RUSTTARGET:+--target $RUSTTARGET}
25+
RUN if [[ ! -z "$RUSTTARGET" ]]; then \
26+
export CC=/$MUSLTARGET-cross/bin/$MUSLTARGET-gcc; \
27+
mkdir .cargo && \
28+
echo "[target.$RUSTTARGET]" > .cargo/config.toml && \
29+
echo "linker = \"$CC\"" >> .cargo/config.toml; \
30+
fi; \
31+
cargo build --release ${RUSTTARGET:+--target $RUSTTARGET} && \
32+
rm src/main.rs target/$RUSTTARGET/release/deps/highlights*
1733
COPY ["src", "./src"]
18-
RUN cargo build --release
34+
RUN if [[ ! -z "$RUSTTARGET" ]]; then \
35+
export CC=/$MUSLTARGET-cross/bin/$MUSLTARGET-gcc; \
36+
fi; \
37+
cargo build --release ${RUSTTARGET:+--target $RUSTTARGET} && \
38+
if [[ ! -z "$RUSTTARGET" ]]; then \
39+
mv target/$RUSTTARGET/release/highlights target/release/highlights; \
40+
fi
1941

2042
FROM alpine:3.15.0
2143
RUN apk add --no-cache --update tini=0.19.0-r0 && \

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ For self-hosters, highlights includes:
1818
## Docker
1919
You can find a Dockerfile in this repository, or use [`thatsnomoon/highlights`](https://hub.docker.com/r/thatsnomoon/highlights). Also provided is a `docker-compose.yml` that will organize Highlights, a Jaeger agent, collector, and query server, and Cassandra, and should set up Cassandra to accept Jaeger logs.
2020

21+
### AArch64, other alternate architectures
22+
23+
The Dockerfile provided supports building to any architecture supported by both Rust and [musl.cc](https://musl.cc). I build `thatsnomoon/highlights` for AArch64 alongside x86_64; if you need a different architecture, use `docker buildx build` with `--platform=linux/<architecture>` and provide appropriate values for the following build args:
24+
- `--build-arg RUSTTARGET=<rust target triple>` (ex: `aarch64-unknown-linux-musl`)
25+
- `--build-arg MUSLHOST=<musl host triple>` (ex: `x86_64-linux-musl`; see [supported musl.cc hosts](https://more.musl.cc/10.2.1))
26+
- `--build-arg MUSLTARGET=<musl target triple>` (ex: `aarch64-linux-musl`; for x86_64, see [supported musl.cc targets here](https://more.musl.cc/10.2.1/x86_64-linux-musl))
27+
2128
## Download
2229
You can find downloads for 64 bit Windows and Linux, as well as 64 bit Linux ARM (for e.g. Raspberry Pi) on [the releases page](https://github.com/ThatsNoMoon/highlights/releases/).
2330

0 commit comments

Comments
 (0)