Skip to content

Commit

Permalink
feat: use zigbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanBorai committed Feb 4, 2024
1 parent 8dba395 commit 27d3dec
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@ jobs:
uses: actions/checkout@v4

- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@master
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: x86_64-unknown-linux-musl

- name: Setup Zig
uses: goto-bus-stop/[email protected]

- name: Install zigbuild
run: cargo install cargo-zigbuild

- name: Install Just
uses: extractions/setup-just@v1

- name: Build Server
run: just build_server
- name: Build Image
run: just docker_build_image
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARG ARCH=

FROM ${ARCH}alpine:3

COPY server /opt/commune

WORKDIR app

ENTRYPOINT ["/opt/commune"]
15 changes: 10 additions & 5 deletions Justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
set positional-arguments

commit_sha := `git rev-parse --verify HEAD`
target_release := "x86_64-unknown-linux-musl"

# Lists all available commands
default:
just --list
Expand Down Expand Up @@ -62,10 +65,12 @@ e2e *args='':
cargo test --package test -- --nocapture --test-threads=1 $1

# Builds the Server binary used in the Docker Image
build_server:
cargo build --release -p server --target x86_64-unknown-linux-musl
ls ./target/x86_64-unknown-linux-musl/release
docker_build_server:
cargo zigbuild --target {{target_release}} --release -p server

# Builds the Docker image for the backend
build_image *args='latest': build_server
docker build -t "commune:$1-aarch64-unknown-linux-musl" .
docker_build_image: docker_build_server
mkdir tmp/
cp ./target/{{target_release}}/release/server ./tmp/server
chmod +x ./tmp/server
docker build -t "commune:{{commit_sha}}-{{target_release}}" --build-arg ARCH=arm64v8/ .

0 comments on commit 27d3dec

Please sign in to comment.