From ffb48462390cfc6c8dc4b656dd575fb5c4e13bc0 Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Sun, 24 Mar 2024 23:27:31 -0500 Subject: [PATCH] fix: Multi-arch upload --- .gitignore | 3 ++- Dockerfile | 4 ++-- Makefile | 12 +++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index b8d6911..4fd7ce8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ -# Ignore cargo build outputs +# Ignore build outputs actix/target +.docker # Ignore SQLite file urls.sqlite diff --git a/Dockerfile b/Dockerfile index 567cb8e..8560074 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM scratch -ARG ARCH=linux/amd64 +ARG TARGETARCH -COPY $ARCH/chhoto-url /chhoto-url +COPY .docker/$TARGETARCH/chhoto-url /chhoto-url COPY ./resources /resources ENTRYPOINT ["/chhoto-url"] diff --git a/Makefile b/Makefile index 62da911..5a2e232 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,20 @@ setup: cargo install cross + docker buildx create --use --platform=linux/arm64,linux/amd64 --name multi-platform-builder + docker buildx inspect --bootstrap build: cross build --release --locked --manifest-path=actix/Cargo.toml --target aarch64-unknown-linux-musl cross build --release --locked --manifest-path=actix/Cargo.toml --target x86_64-unknown-linux-musl docker: build - mkdir -p linux/amd64 linux/arm64 - cp actix/target/aarch64-unknown-linux-musl/release/chhoto-url linux/aarch64/ - cp actix/target/x86_64-unknown-linux-musl/release/chhoto-url linux/amd64/ - docker buildx -t chhoto-url --platform linux/amd64,linux/arm64,linux/arm/v7 . - rm -rf linux + mkdir -p .docker/amd64 .docker/arm64 + cp actix/target/aarch64-unknown-linux-musl/release/chhoto-url .docker/arm64/ + cp actix/target/x86_64-unknown-linux-musl/release/chhoto-url .docker/amd64/ + docker buildx build --push --tag sintan1729/chhoto-url:dev --platform linux/amd64,linux/arm64 . clean: cargo clean --manifest-path=actix/Cargo.toml + rm -rf .docker .PHONY: build clean docker