Skip to content

Commit

Permalink
chore: Add Dockerfile and instructions for building ruby gem locally
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecsl committed Dec 6, 2024
1 parent 38a92e7 commit fa142ce
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 17 deletions.
42 changes: 26 additions & 16 deletions ruby-sdk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions ruby-sdk/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM ruby:3.3

ARG WORKDIR

RUN apt-get update && apt-get install -y \
curl \
build-essential \
libssl-dev \
zlib1g-dev \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

RUN apt-get install ca-certificates curl
RUN install -m 0755 -d /etc/apt/keyrings
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
RUN chmod a+r /etc/apt/keyrings/docker.asc

RUN echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
RUN apt-get update
RUN apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

WORKDIR $WORKDIR

RUN gem install rb_sys

COPY build.sh ./

CMD ["/bin/bash", "./build.sh"]
12 changes: 12 additions & 0 deletions ruby-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,15 @@ Make sure you remove the override before updating `Cargo.lock`. Otherwise, the l
* Bump versions in `ruby-sdk/lib/eppo_client/version.rb` and `ruby-sdk/ext/eppo_client/Cargo.toml`
* Run `cargo update --workspace --verbose` to update `Cargo.lock`
* Run `bundle` to update `Gemfile.lock`


## Building native libs

```
docker build --build-arg WORKDIR=$(pwd) -t ruby-sdk-builder .
mkdir -p rust/cargo/registry
docker run --rm -it \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp:/tmp -v \
$(pwd)/rust:$(pwd)/rust ruby-sdk-builder
```
11 changes: 11 additions & 0 deletions ruby-sdk/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set -e
export RUST_INSTALL_PATH=./rust
mkdir -p $RUST_INSTALL_PATH
export RUSTUP_HOME=$RUST_INSTALL_PATH/rustup
export CARGO_HOME=$RUST_INSTALL_PATH/cargo
export PATH=$CARGO_HOME/bin:$PATH
export RB_SYS_DOCK_CACHE_DIR=./cache
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
rustup install stable
rustup default stable
rb-sys-dock --platform aarch64-linux-musl --mount-toolchains --ruby-versions 3.3 -V --build -V
2 changes: 1 addition & 1 deletion ruby-sdk/ext/eppo_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ crate-type = ["cdylib"]

[dependencies]
env_logger = { version = "0.11.3", features = ["unstable-kv"] }
eppo_core = { version = "=5.0.0", features = ["vendored"] }
eppo_core = { version = "=4.1.1", features = ["vendored"] }
log = { version = "0.4.21", features = ["kv_serde"] }
magnus = { version = "0.6.4" }
serde = { version = "1.0.203", features = ["derive"] }
Expand Down

0 comments on commit fa142ce

Please sign in to comment.