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

Install LLVM 17 by default, Automatically install correct Rust version as default t… #4

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
19 changes: 14 additions & 5 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,33 @@ jobs:

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

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

- name: Login to Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set tag name based on branch
id: set-tag-name
run: |
if [ "${{ github.ref_name }}" = "main" ]; then
echo "tag_name=falkordb-build:${{ matrix.os }}" >> $GITHUB_OUTPUT
else
echo "tag_name=falkordb-build:${{ github.ref_name }}-${{ matrix.os }}" >> $GITHUB_OUTPUT
fi

- name: Build and push ${{ matrix.os }} image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.${{ matrix.os }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
push: true
tags: falkordb/falkordb-build:${{ matrix.os }}
tags: falkordb/${{ steps.set-tag-name.outputs.tag_name }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
44 changes: 38 additions & 6 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
FROM debian:bookworm-slim
FROM debian:bookworm-slim AS base

RUN apt-get update -y && apt-get install -y build-essential cmake m4 automake peg libtool autoconf python3 python3-pip git peg lcov openssl libssl-dev
RUN apt update && apt install -y \
automake build-essential cmake curl git gnupg \
lcov libc6-dbg libssl-dev libtool lsb-release m4 openssl \
peg python3 python3-pip python3-venv \
software-properties-common wget

# install rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# Add docker repo
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker.gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs 2> /dev/null) stable" > /etc/apt/sources.list.d/docker.list
RUN apt update && apt install -y containerd.io docker-buildx-plugin docker-ce docker-ce-cli docker-compose-plugin

# add rust to path
ENV PATH="/root/.cargo/bin:${PATH}"
# Get LLVM, Clang
ARG LLVM_VERSION=17

RUN wget https://apt.llvm.org/llvm.sh
RUN chmod +x llvm.sh
RUN ./llvm.sh ${LLVM_VERSION}
RUn apt update -y && apt install -y clang-${LLVM_VERSION} libomp-${LLVM_VERSION}-dev lld-${LLVM_VERSION} lldb-${LLVM_VERSION}
RUN rm llvm.sh

COPY set_alternatives.sh .
RUN ./set_alternatives.sh ${LLVM_VERSION}
RUN rm set_alternatives.sh

# install Rust using rustup, set toolchain to 1.77 as default until we upgrade to LLVM 18/19
ARG TOOLCHAIN_VERSION=1.77
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${TOOLCHAIN_VERSION}

# Clear cache before copying to scratch
RUN apt autoremove -y && apt clean

# Delete doc directory as it is unneeded and heavy
RUN rm -r /usr/share/doc /root/.rustup/toolchains/${TOOLCHAIN_VERSION}-$(uname -m)-unknown-linux-gnu/share/doc

FROM scratch
COPY --from=base / /

# add rust to path for new image
ENV PATH="/root/.cargo/bin:${PATH}"
37 changes: 32 additions & 5 deletions Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
FROM ubuntu:22.04 as builder
FROM phusion/baseimage:jammy-1.0.4 AS base

RUN apt-get update -y && apt-get install -y curl build-essential cmake m4 automake peg libtool autoconf python3 python3-pip git peg lcov openssl libssl-dev
RUN apt update -y && apt install -y \
automake build-essential cmake curl docker-buildx \
docker-compose-v2 git gnupg lcov libc6-dbg libssl-dev \
libtool lsb-release m4 openssl peg pkgconf python3 \
python3-pip python3-venv software-properties-common wget

# install rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# Get LLVM, Clang
ARG LLVM_VERSION=17

# add rust to path
RUN wget https://apt.llvm.org/llvm.sh
RUN chmod +x llvm.sh
RUN ./llvm.sh ${LLVM_VERSION}
RUn apt update -y && apt install -y clang-${LLVM_VERSION} libomp-${LLVM_VERSION}-dev lld-${LLVM_VERSION} lldb-${LLVM_VERSION}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix typo in RUN command.

There is a typo in the RUN command.

- RUn apt update -y && apt install -y clang-${LLVM_VERSION} libomp-${LLVM_VERSION}-dev lld-${LLVM_VERSION} lldb-${LLVM_VERSION}
+ RUN apt update -y && apt install -y clang-${LLVM_VERSION} libomp-${LLVM_VERSION}-dev lld-${LLVM_VERSION} lldb-${LLVM_VERSION}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RUn apt update -y && apt install -y clang-${LLVM_VERSION} libomp-${LLVM_VERSION}-dev lld-${LLVM_VERSION} lldb-${LLVM_VERSION}
RUN apt update -y && apt install -y clang-${LLVM_VERSION} libomp-${LLVM_VERSION}-dev lld-${LLVM_VERSION} lldb-${LLVM_VERSION}

RUN rm llvm.sh

COPY set_alternatives.sh .
RUN ./set_alternatives.sh ${LLVM_VERSION}
RUN rm set_alternatives.sh

# install Rust using rustup, set toolchain to 1.77 as default until we upgrade to LLVM 18/19
ARG TOOLCHAIN_VERSION=1.77
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${TOOLCHAIN_VERSION}

# Clear cache before copying to scratch
RUN apt autoremove -y && apt clean

# Delete doc directory as it is unneeded and heavy
RUN rm -r /usr/share/doc /root/.rustup/toolchains/${TOOLCHAIN_VERSION}-$(uname -m)-unknown-linux-gnu/share/doc

FROM scratch
COPY --from=base / /

# add rust to path for new image
ENV PATH="/root/.cargo/bin:${PATH}"
22 changes: 22 additions & 0 deletions set_alternatives.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#! /bin/bash

set -e

LLVM_VERSION=$1
if [ -z "$LLVM_VERSION" ]; then
echo "Usage: $0 <llvm_version>"
exit 1
fi

update-alternatives --install /usr/bin/clang clang "/usr/bin/clang-${LLVM_VERSION}" 100
update-alternatives --install /usr/bin/clang++ clang++ "/usr/bin/clang++-${LLVM_VERSION}" 100
update-alternatives --install /usr/bin/ld ld "/usr/bin/lld-${LLVM_VERSION}" 100
update-alternatives --install /usr/bin/lldb lldb "/usr/bin/lldb-${LLVM_VERSION}" 100
update-alternatives --install /usr/bin/llvm-cov llvm-cov "/usr/bin/llvm-cov-${LLVM_VERSION}" 100
update-alternatives --install /usr/bin/llvm-profdata llvm-profdata "/usr/bin/llvm-profdata-${LLVM_VERSION}" 100
update-alternatives --install /usr/bin/llvm-ranlib llvm-ranlib "/usr/bin/llvm-ranlib-${LLVM_VERSION}" 100
update-alternatives --install /usr/bin/llvm-strip llvm-strip "/usr/bin/llvm-strip-${LLVM_VERSION}" 100
update-alternatives --install /usr/bin/llvm-symbolizer llvm-symbolizer "/usr/bin/llvm-symbolizer-${LLVM_VERSION}" 100

# Rust needs this to find libclang when using the cc crate
ln -sf "/usr/lib/$(gcc -dumpmachine)/libclang-${LLVM_VERSION}.so.1" /usr/lib/"$(gcc -dumpmachine)"/libclang.so