Skip to content

Commit

Permalink
cross compile for pi, update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Austionian committed Oct 25, 2024
1 parent 6e0c0ba commit a0e4225
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-gnu-gcc"
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ tower-http = { version = "0.6", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
uuid = { version = "1.4", features = ["serde"] }

[dependencies.openssl-sys]
version = "0.9"
features = ["vendored"]
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
FROM rust:1.81 AS chef
FROM --platform=$BUILDPLATFORM rust:latest AS chef

WORKDIR /app

USER root:root

RUN apt update && apt upgrade
RUN apt install -y gcc-aarch64-linux-gnu

RUN rustup target add aarch64-unknown-linux-musl

RUN cargo install --locked cargo-chef sccache
ENV RUSTC_WRAPPER=sccache SCCACHE_DIR=/sccache

Expand All @@ -19,11 +26,11 @@ COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
cargo build --release
cargo build --release --target aarch64-unknown-linux-musl

FROM gcr.io/distroless/cc-debian12 AS runtime
FROM --platform=$BUILDPLATFORM alpine:3.14 AS runtime
WORKDIR /app
COPY --from=builder /app/target/release/bl0g bl0g
COPY --from=builder /app/target/aarch64-unknown-linux-musl/release/bl0g bl0g
COPY config config
COPY assets assets
COPY templates templates
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ services:
- "1111:1111"
environment:
API_TOKEN: ${API_TOKEN}
platform: linux/arm64
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ update:

# Builds the docker image
docker-build:
docker build --tag bl0g --file Dockerfile .
docker buildx build --platform linux/arm64/v8 --tag bl0g --file Dockerfile .

docker-deploy:
DOCKER_HOST="ssh://austin@raspberrypi.local" docker compose up -d
Expand Down

0 comments on commit a0e4225

Please sign in to comment.