Skip to content

Commit

Permalink
wip: try multi-arch
Browse files Browse the repository at this point in the history
  • Loading branch information
uatuko committed Nov 10, 2024
1 parent 53450bf commit 9f722f2
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 68 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

jobs:
coverage:
if: false
name: Code coverage
runs-on: ubuntu-latest
concurrency:
Expand Down
20 changes: 17 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
release:
types:
- published
pull_request:
workflow_dispatch:

jobs:
Expand All @@ -17,29 +18,42 @@ jobs:
contents: read
packages: write
steps:
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
- uses: docker/metadata-action@v5
id: meta
with:
images: uatuko/ruek
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=latest
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and publish
uses: docker/build-push-action@v6
with:
annotations: ${{ steps.meta.outputs.annotations }}
context: .
file: Containerfile
platforms: |
linux/amd64
linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
- uses: actions/delete-package-versions@v5
with:
package-name: ruek
package-type: container
min-versions-to-keep: 2
delete-only-untagged-versions: true
23 changes: 18 additions & 5 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
FROM debian:12-slim as builder
FROM --platform=$BUILDPLATFORM debian:12-slim as builder

Check warning on line 1 in Containerfile

View workflow job for this annotation

GitHub Actions / container

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

ARG TARGETARCH

COPY . /tmp/source
WORKDIR /tmp

RUN apt-get update \
&& \
ruek_march=$(./source/bin/march.sh) \
&& \
if [ "$ruek_march" = "x86_64" ]; then ruek_march=x86-64; fi \
&& \
apt-get install -y --no-install-recommends \
binutils-${ruek_march}-linux-gnu \
cmake ninja-build \
clang libclang-rt-dev \
g++ \
protobuf-compiler libprotobuf-dev libprotoc-dev \
libpq-dev

COPY . /tmp/source
WORKDIR /tmp

RUN cmake -B build -G Ninja -S source/ \
-DCMAKE_BUILD_TYPE=Release \
-DRUEK_BUILD_TESTING=OFF
RUN ruek_march=$(./source/bin/march.sh) \
&& \
cmake -B build -G Ninja -S source/ \
-DCMAKE_CXX_COMPILER_TARGET=${ruek_march}-linux-gnu \
-DCMAKE_BUILD_TYPE=Release \
-DRUEK_BUILD_TESTING=OFF

RUN cmake --build build/ --config Release

Expand Down
18 changes: 18 additions & 0 deletions bin/march.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env sh

: ${ruek_march=unknown}

if [ -z ${TARGETARCH} ]; then
TARGETARCH=$(uname -m)
fi

case ${TARGETARCH} in
amd64 | x86_64)
ruek_march=x86_64
;;
aarch64 | arm64)
ruek_march=aarch64
;;
esac

echo ${ruek_march}
20 changes: 10 additions & 10 deletions src/svc/authz.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ class Impl {
return {grpcxx::status::code_t::unimplemented, std::nullopt};
}

template <>
rpcCheck::result_type call<rpcCheck>(grpcxx::context &ctx, const rpcCheck::request_type &req);

template <>
rpcGrant::result_type call<rpcGrant>(grpcxx::context &ctx, const rpcGrant::request_type &req);

template <>
rpcRevoke::result_type call<rpcRevoke>(
grpcxx::context &ctx, const rpcRevoke::request_type &req);

google::rpc::Status exception() noexcept;

private:
Expand All @@ -35,5 +25,15 @@ class Impl {
db::Tuple map(const grpcxx::context &ctx, const rpcGrant::request_type &from) const noexcept;
rpcGrant::response_type map(const db::Tuple &from) const noexcept;
};

template <>
rpcCheck::result_type Impl::call<rpcCheck>(grpcxx::context &ctx, const rpcCheck::request_type &req);

template <>
rpcGrant::result_type Impl::call<rpcGrant>(grpcxx::context &ctx, const rpcGrant::request_type &req);

template <>
rpcRevoke::result_type Impl::call<rpcRevoke>(
grpcxx::context &ctx, const rpcRevoke::request_type &req);
} // namespace authz
} // namespace svc
24 changes: 12 additions & 12 deletions src/svc/entities.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ class Impl {
return {grpcxx::status::code_t::unimplemented, std::nullopt};
}

template <>
rpcList::result_type call<rpcList>(grpcxx::context &ctx, const rpcList::request_type &req);

template <>
rpcListPrincipals::result_type call<rpcListPrincipals>(
grpcxx::context &ctx, const rpcListPrincipals::request_type &req);

google::rpc::Status exception() noexcept;

private:
template <typename T, typename F> T map(const F &) const noexcept;
};

template <> rpcList::response_type map(const db::Tuples &from) const noexcept;
template <> rpcListPrincipals::response_type map(const db::Tuples &from) const noexcept;
template <>
rpcList::result_type Impl::call<rpcList>(grpcxx::context &ctx, const rpcList::request_type &req);

template <> ruek::api::v1::EntitiesEntity map(const db::Tuple &from) const noexcept;
template <> ruek::api::v1::EntitiesPrincipal map(const db::Tuple &from) const noexcept;
};
template <>
rpcListPrincipals::result_type Impl::call<rpcListPrincipals>(
grpcxx::context &ctx, const rpcListPrincipals::request_type &req);

template <> rpcList::response_type Impl::map(const db::Tuples &from) const noexcept;
template <> rpcListPrincipals::response_type Impl::map(const db::Tuples &from) const noexcept;

template <> ruek::api::v1::EntitiesEntity Impl::map(const db::Tuple &from) const noexcept;
template <> ruek::api::v1::EntitiesPrincipal Impl::map(const db::Tuple &from) const noexcept;
} // namespace entities
} // namespace svc
38 changes: 19 additions & 19 deletions src/svc/principals.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,6 @@ class Impl {
return {grpcxx::status::code_t::unimplemented, std::nullopt};
}

template <>
rpcCreate::result_type call<rpcCreate>(
grpcxx::context &ctx, const rpcCreate::request_type &req);

template <>
rpcDelete::result_type call<rpcDelete>(
grpcxx::context &ctx, const rpcDelete::request_type &req);

template <>
rpcList::result_type call<rpcList>(grpcxx::context &ctx, const rpcList::request_type &req);

template <>
rpcRetrieve::result_type call<rpcRetrieve>(
grpcxx::context &ctx, const rpcRetrieve::request_type &req);

template <>
rpcUpdate::result_type call<rpcUpdate>(
grpcxx::context &ctx, const rpcUpdate::request_type &req);

google::rpc::Status exception() noexcept;

private:
Expand All @@ -46,5 +27,24 @@ class Impl {
rpcCreate::response_type map(const db::Principal &from) const noexcept;
rpcList::response_type map(const db::Principals &from) const noexcept;
};

template <>
rpcCreate::result_type Impl::call<rpcCreate>(
grpcxx::context &ctx, const rpcCreate::request_type &req);

template <>
rpcDelete::result_type Impl::call<rpcDelete>(
grpcxx::context &ctx, const rpcDelete::request_type &req);

template <>
rpcList::result_type Impl::call<rpcList>(grpcxx::context &ctx, const rpcList::request_type &req);

template <>
rpcRetrieve::result_type Impl::call<rpcRetrieve>(
grpcxx::context &ctx, const rpcRetrieve::request_type &req);

template <>
rpcUpdate::result_type Impl::call<rpcUpdate>(
grpcxx::context &ctx, const rpcUpdate::request_type &req);
} // namespace principals
} // namespace svc
38 changes: 19 additions & 19 deletions src/svc/relations.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,6 @@ class Impl {
return {grpcxx::status::code_t::unimplemented, std::nullopt};
}

template <>
rpcCheck::result_type call<rpcCheck>(grpcxx::context &ctx, const rpcCheck::request_type &req);

template <>
rpcCreate::result_type call<rpcCreate>(
grpcxx::context &ctx, const rpcCreate::request_type &req);

template <>
rpcDelete::result_type call<rpcDelete>(
grpcxx::context &ctx, const rpcDelete::request_type &req);

template <>
rpcListLeft::result_type call<rpcListLeft>(
grpcxx::context &ctx, const rpcListLeft::request_type &req);

template <>
rpcListRight::result_type call<rpcListRight>(
grpcxx::context &ctx, const rpcListRight::request_type &req);

google::rpc::Status exception() noexcept;

private:
Expand Down Expand Up @@ -71,5 +52,24 @@ class Impl {
std::string_view spaceId, db::Tuple::Entity left, std::string_view relation,
db::Tuple::Entity right, std::uint16_t limit) const;
};

template <>
rpcCheck::result_type Impl::call<rpcCheck>(grpcxx::context &ctx, const rpcCheck::request_type &req);

template <>
rpcCreate::result_type Impl::call<rpcCreate>(
grpcxx::context &ctx, const rpcCreate::request_type &req);

template <>
rpcDelete::result_type Impl::call<rpcDelete>(
grpcxx::context &ctx, const rpcDelete::request_type &req);

template <>
rpcListLeft::result_type Impl::call<rpcListLeft>(
grpcxx::context &ctx, const rpcListLeft::request_type &req);

template <>
rpcListRight::result_type Impl::call<rpcListRight>(
grpcxx::context &ctx, const rpcListRight::request_type &req);
} // namespace relations
} // namespace svc

0 comments on commit 9f722f2

Please sign in to comment.