Skip to content

[draft] How to build the develoment docker image

mu edited this page May 22, 2023 · 15 revisions

If you just want to compile the hstream project, this manual is not for you.

Prepare

# logdevice
git clone --recurse-submodules https://github.com/hstreamdb/LogDevice.git

# all other dependencies
git clone --recurse-submodules https://github.com/hstreamdb/docker-haskell.git

Note that any updating push to docker-haskell's release branch will auto-release the image by GitHub ci. So that you don't need to build it manually. A command ./gen_checksum.sh may require to be run after the image is pushed.

Build LogDevice

NOTE: if you want to build an arm64 image on a 64c32g amd64 machine with the default build args, it may fail because of oom. Instead, you can limit the threads used by docker with --build-arg PARALLEL=32 to decrease memory usage.

cd LogDevice

# zookeeper based
git checkout -b stable upstream/stable
docker build . -f docker/Dockerfile.builder --tag hstreamdb/logdevice-builder
# Or use buildx to build multiplatform images, e.g.
# docker buildx build --platform linux/amd64,linux/arm64 --push -f docker/Dockerfile.builder --tag hstreamdb/logdevice-builder .

docker build . -f docker/Dockerfile --tag hstreamdb/logdevice
docker build . -f docker/Dockerfile --tag hstreamdb/logdevice-client --target client

# rqlite based
git checkout main
docker build . -f docker/Dockerfile.builder --tag hstreamdb/logdevice-builder:rqlite

docker build . -f docker/Dockerfile --tag hstreamdb/logdevice:rqlite
docker build . -f docker/Dockerfile --tag hstreamdb/logdevice-client:rqlite --target client

Build grpc

cd docker-haskell

# NOTE: v1.35.0 is the version we currently use, and this manual may be outdated.
docker build . -f dockerfiles/grpc -t ghcr.io/hstreamdb/grpc:1.35.0

Build ghc

For example, ghc-8.10.7:

# You can get your sha256sum from: https://downloads.haskell.org/~ghc/8.10.7/SHA256SUMS
docker build . -f dockerfiles/ghc_from_haskell --build-arg GHC=8.10.7 --build-arg GHC_RELEASE_SHA256=b6ed67049a23054a8042e65c9976d5e196e5ee4e83b29b2ee35c8a22ab1e5b73 -t ghcr.io/hstreamdb/ghc:8.10.7

Build hsthrift

docker build . -f dockerfiles/hsthrift -t ghcr.io/hstreamdb/hsthrift

Build hadmin-store

docker build . -f dockerfiles/hadmin_store -t ghcr.io/hstreamdb/hadmin-store:latest

Build haskell

For example, ghc-9.2.7:

# with zookeeper based logdevice
docker build . -f Dockerfile \
  --build-arg GHC=9.2.7 \
  --build-arg LD_CLIENT_IMAGE=hstreamdb/logdevice-client \
  --tag hstreamdb/haskell:9.2.7

# with rqlite based logdevice
docker build . -f Dockerfile \
  --build-arg GHC=9.2.7 \
  --build-arg LD_CLIENT_IMAGE=hstreamdb/logdevice-client:rqlite \
  --tag hstreamdb/haskell:rqlite_9.2.7

The default password of the root user is toor. So that you can install any other dependencies inside the container if you need.