From d8e1e375bc41b9dd347cb84c203c8aea4187ed44 Mon Sep 17 00:00:00 2001 From: Alexey Aristov Date: Thu, 4 Sep 2025 13:54:03 +0200 Subject: [PATCH] build github action Signed-off-by: Alexey Aristov --- .github/workflows/build.yaml | 31 +++++++++++++++++++++++++++++++ Justfile | 2 ++ server/Dockerfile | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 Justfile create mode 100644 server/Dockerfile diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000000..d990eb67f7 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,31 @@ +name: Build and Push + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Log to registry + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKER_USER }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + + - run: echo VERSION=$(grep '^version =' server/Cargo.toml | cut -d '"' -f 2) >> $GITHUB_ENV + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and Push + uses: docker/build-push-action@v6 + with: + file: server/Dockerfile + push: true + tags: "${{ vars.DOCKER_USER }}/service_hulylake:latest" + platforms: linux/amd64,linux/arm64 diff --git a/Justfile b/Justfile new file mode 100644 index 0000000000..825705f974 --- /dev/null +++ b/Justfile @@ -0,0 +1,2 @@ +image: + cd server && docker buildx build --tag=hardcoreeng/hulylake:latest --platform=linux/amd64 --load . \ No newline at end of file diff --git a/server/Dockerfile b/server/Dockerfile new file mode 100644 index 0000000000..2132b5ede7 --- /dev/null +++ b/server/Dockerfile @@ -0,0 +1,32 @@ +FROM --platform=$BUILDPLATFORM rust:1.88 AS builder +ARG TARGETPLATFORM + +WORKDIR /tmp/build + +COPY . . + +RUN \ + if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ + cargo build --release --target=x86_64-unknown-linux-gnu ; \ + elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ + apt-get update && apt-get install -y \ + gcc-aarch64-linux-gnu \ + g++-aarch64-linux-gnu \ + libc6-dev-arm64-cross \ + && rm -rf /var/lib/apt/lists/* ; \ + rustup target add aarch64-unknown-linux-gnu ; \ + export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc ; \ + export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ ; \ + export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc ; \ + cargo build --release --target=aarch64-unknown-linux-gnu ; \ + else \ + echo "Unexpected target platform: $TARGETPLATFORM" && exit 1 ; \ + fi + +FROM debian:12-slim + +ARG TARGET +COPY --from=builder /tmp/build/target/*/release/hulylake /usr/local/bin/hulylake +RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/* + +ENTRYPOINT ["/usr/local/bin/hulykvs"]