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/
34 changes: 28 additions & 6 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
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 -y && apt install -y \
automake build-essential cmake curl git \
gnupg lcov 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
RUN apt update -y && apt upgrade -y

# 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} all
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}

FROM scratch
COPY --from=base / /

# add rust to path for new image
ENV PATH="/root/.cargo/bin:${PATH}"
32 changes: 27 additions & 5 deletions Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
FROM ubuntu:22.04 as builder
FROM ubuntu:jammy 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 git \
gnupg lcov 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
RUN apt update -y && apt upgrade -y

# add rust to 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} all
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}

FROM scratch
COPY --from=base / /

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

LLVM_VERSION=$1

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/clang-format clang-format "/usr/bin/clang-format-${LLVM_VERSION}" 100
update-alternatives --install /usr/bin/clang-tidy clang-tidy "/usr/bin/clang-tidy-${LLVM_VERSION}" 100
update-alternatives --install /usr/bin/clangd clangd "/usr/bin/clangd-${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-config llvm-config "/usr/bin/llvm-config-${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

# 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