Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(workflows) add GitHub Actions workflow for preview builds #2446

Merged
merged 32 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
target/
.git/
.github/
.idea/
.vscode/
.devcontainer/
.cargo/
45 changes: 45 additions & 0 deletions .github/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM rust:1.80.0-slim as chef

# Install libclang and other necessary tools
RUN apt-get update && \
apt-get install -y clang llvm-dev libclang-dev git libtool automake autoconf make curl
glihm marked this conversation as resolved.
Show resolved Hide resolved

RUN apt-get install -y protobuf-compiler

# Verify and set LIBCLANG_PATH environment variable
RUN find /usr -name "libclang.so*" && \
export LIBCLANG_PATH=$(find /usr -name "libclang.so*" | head -n 1 | xargs dirname)

RUN rustup install 1.79.0
RUN rustup component add cargo clippy rust-docs rust-std rustc rustfmt

RUN cargo install cargo-chef

FROM chef AS planner

WORKDIR /app
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder

WORKDIR /app
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --recipe-path recipe.json
RUN cargo build --release --bins

# Build application
COPY . .
ENV PATH="/root/.cargo/bin:${PATH}"

RUN cargo build --release --bins
steebchen marked this conversation as resolved.
Show resolved Hide resolved

FROM rust:1-alpine

WORKDIR /

COPY --from=builder /app/target/release/katana /app/artifacts/
COPY --from=builder /app/target/release/torii /app/artifacts/
COPY --from=builder /app/target/release/sozo /app/artifacts/
COPY --from=builder /app/target/release/saya /app/artifacts/
glihm marked this conversation as resolved.
Show resolved Hide resolved
57 changes: 57 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: preview

on:
workflow_dispatch:
push:
branches:
- ci-preview
glihm marked this conversation as resolved.
Show resolved Hide resolved

jobs:
build-and-push:
name: Build and push
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ github.ref_name }}
${{ runner.os }}-buildx-

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set outputs
id: vars
run: |
git config --global --add safe.directory "${{ github.workspace }}"
echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"

- name: Build binaries
run: |
docker build -t build -f .github/Dockerfile .
docker run --rm -v $(pwd)/artifacts:/artifacts build /bin/sh -c "cp -r /app/artifacts/* /artifacts"
steebchen marked this conversation as resolved.
Show resolved Hide resolved

- name: Build and push docker image
uses: docker/build-push-action@v3
with:
push: true
tags: ghcr.io/${{ github.repository }}:preview--${{ steps.vars.outputs.sha_short }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
platforms: linux/amd64
build-contexts: |
artifacts=artifacts
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ RUN git clone https://github.com/Comcast/Infinite-File-Curtailer.git curtailer \
&& make install \
&& curtail --version

ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--"]

FROM debian:bookworm-slim as base

ARG TARGETPLATFORM
Expand Down
Loading