Dockerfile:
# Build Glean from source
# Based on https://github.com/facebookincubator/Glean/blob/main/Dockerfile
FROM ghcr.io/facebookincubator/hsthrift/ci-base:latest AS builder
RUN rm -rf /usr/local/lib /usr/local/include
RUN apt-get update && apt-get install -y \
cmake \
ninja-build \
libxxhash-dev \
wget \
unzip \
rsync \
libgmock-dev \
gcc-10 \
g++-10 \
libbz2-dev \
libgmp-dev \
libnuma-dev \
&& rm -rf /var/lib/apt/lists/* \
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100 \
&& update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-10 100 \
&& update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-10 100
# Install GHC 9.4.7 via ghcup (OverloadedRecordDot requires 9.2+)
ENV PATH=/root/.ghcup/bin:/root/.cabal/bin:$PATH
RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \
BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \
BOOTSTRAP_HASKELL_GHC_VERSION=9.4.7 \
BOOTSTRAP_HASKELL_CABAL_VERSION=3.10.3.0 \
BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 \
sh
RUN cabal update
WORKDIR /glean-code
# Clone Glean (for build infrastructure)
RUN git clone --depth 1 https://github.com/facebookincubator/Glean.git .
# Clone hsthrift
RUN mkdir -p hsthrift && cd hsthrift && git clone --depth 1 https://github.com/facebookincubator/hsthrift.git .
# Install dependencies with patching for folly bugs (expensive - should be cached)
# First run clones deps and will fail on folly build, then we patch and retry
RUN ./install_deps.sh || true && \
FOLLY_PATH="/tmp/fbcode_builder_getdeps-Zglean-codeZhsthriftZbuildZfbcode_builder-root/repos/github.com-facebook-folly.git" && \
if [ -d "$FOLLY_PATH" ]; then \
echo "Patching folly..." && \
sed -i 's/^FOLLY_DETAIL_LITE_TUPLE_ADJUST_WARNINGS$/#ifdef FOLLY_DETAIL_LITE_TUPLE_ADJUST_WARNINGS\nFOLLY_DETAIL_LITE_TUPLE_ADJUST_WARNINGS\n#endif/' "$FOLLY_PATH/folly/lang/MustUseImmediately.h" && \
sed -i 's/args\.envv = env ? envHolder\.get() : environ;/args.envv = env ? envHolder.get() : const_cast<const char**>(environ);/' "$FOLLY_PATH/folly/Subprocess.cpp" && \
echo "Patches applied. Retrying build..." && \
./install_deps.sh; \
else \
echo "Folly not found" && exit 1; \
fi
ENV LD_LIBRARY_PATH=/root/.hsthrift/lib
ENV PKG_CONFIG_PATH=/root/.hsthrift/lib/pkgconfig
ENV PATH=$PATH:/root/.hsthrift/bin
# Setup folly sources for folly-clib Hackage package
RUN cd hsthrift && make setup-folly && make setup-folly-version
# Use pkg-config folly instead of bundled
ENV CABAL_CONFIG_FLAGS="-f-bundled-folly"
# Exclude glean-lsp (requires GHC 9.2+ for NoFieldSelectors)
# Remove -Werror to avoid warnings-as-errors breaking the build
# Add -fpermissive for folly-clib C++ compilation
# Add extra-lib-dirs and explicit linker flags for folly
RUN sed -i '/glean\/lsp/d' cabal.project && \
sed -i '/package glean-lsp/{N;d}' cabal.project && \
sed -i 's/ghc-options: -Werror/ghc-options:/' cabal.project && \
echo "" >> cabal.project && \
echo "extra-lib-dirs: /root/.hsthrift/lib" >> cabal.project && \
echo "extra-include-dirs: /root/.hsthrift/include" >> cabal.project && \
echo "package *" >> cabal.project && \
echo " ghc-options: -optl-L/root/.hsthrift/lib -optl-Wl,-rpath,/root/.hsthrift/lib" >> cabal.project && \
echo "package folly-clib" >> cabal.project && \
echo " ghc-options: -optc-fpermissive -optcxx-fpermissive" >> cabal.project
# Build Glean with explicit folly library linking
ENV LDFLAGS="-L/root/.hsthrift/lib -lfolly -Wl,-rpath,/root/.hsthrift/lib"
RUN make
# Copy binaries to known location
RUN mkdir -p /out/bin /out/lib /out/schema
RUN cp $(cabal -v0 list-bin glean) /out/bin/
RUN cp $(cabal -v0 list-bin glean-server) /out/bin/
RUN cp $(cabal -v0 list-bin glean-hyperlink) /out/bin/
# Copy all required shared libraries from builder
RUN cp -r /root/.hsthrift/lib/* /out/lib/ && \
for lib in libicu libboost libssl libcrypto libglog libgflags \
libunwind libdouble-conversion libevent libsodium \
libsnappy liblz4 libzstd libbz2 liblzma libxxhash \
libmysqlclient libjemalloc librocksdb libfmt; do \
cp /usr/lib/x86_64-linux-gnu/${lib}*.so* /out/lib/ 2>/dev/null || true; \
done
RUN cp -r glean/schema/source /out/schema/
# Verify binaries work
RUN /out/bin/glean --help
# =============================================================================
# Runtime image
# =============================================================================
FROM ubuntu:22.04 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
# Runtime dependencies
RUN apt-get update && apt-get install -y \
libicu70 \
libboost-context1.74.0 \
libboost-filesystem1.74.0 \
libboost-program-options1.74.0 \
libboost-regex1.74.0 \
libunwind8 \
libgoogle-glog0v5 \
libssl3 \
libsodium23 \
libdouble-conversion3 \
libmysqlclient21 \
libevent-2.1-7 \
libsnappy1v5 \
libxxhash0 \
libatomic1 \
# Tools for indexers
curl \
git \
jq \
# Node.js for TypeScript indexer
nodejs \
npm \
# Python for scip-python
python3 \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
# Install Go 1.24
RUN curl -fsSL https://go.dev/dl/go1.24.3.linux-amd64.tar.gz | tar -C /usr/local -xzf -
ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH
# Install LSIF/SCIP indexers
RUN npm install -g @sourcegraph/lsif-tsc @sourcegraph/scip-typescript @sourcegraph/scip-python
RUN go install github.com/sourcegraph/scip-go/cmd/scip-go@latest
ENV PATH=/glean/bin:$PATH
ENV LD_LIBRARY_PATH=/glean/lib
WORKDIR /glean
# Copy Glean binaries and schema from builder
COPY --from=builder /out/bin /glean/bin
COPY --from=builder /out/lib /glean/lib
COPY --from=builder /out/schema /glean/schema
# Verify
RUN /glean/bin/glean --help
EXPOSE 12345 8888
CMD ["glean-server", "--db-root", "/data/db", "--schema", "dir:/glean/schema/source", "--port", "12345"]
Content type
Image
Digest
sha256:64fc28507…
Size
1 GB
Last updated
9 months ago
docker pull dgellow/glean