├── .dockerignore ├── .gitignore ├── Dockerfile ├── README.md ├── build.sh └── run-builder.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | /mongodb-linux-x86_64-* 2 | /mongodb-src-r* 3 | /*.tgz 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /mongodb-linux-x86_64-* 2 | /mongodb-src-r* 3 | /*.tgz 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | 3 | 4 | RUN apt update 5 | RUN apt install -y python3 python3-pip 6 | RUN apt install python-dev-is-python3 libssl-dev liblzma-dev -y 7 | RUN apt-get install build-essential -y 8 | 9 | ADD build.sh . 10 | ENTRYPOINT ["/build.sh"] 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MongoDB Builder for Linux 2 | 3 | This Docker image builds MongoDB for Linux from source without OpenSSL and cURL, similar to the generic Linux packages 4 | that 5 | are [not provided anymore since MongoDB 4.2](https://www.mongodb.com/blog/post/a-proposal-to-endoflife-our-generic-linux-tar-packages). 6 | 7 | ## Building the Image 8 | 9 | ```sh 10 | docker build -t mongodb-builder . 11 | ``` 12 | 13 | ## Usage 14 | 15 | The `run-builder.sh` script downloads the MongoDB source, builds `mongod` and `mongo`, and creates an 16 | archive (`mongodb-linux-x86_64-*.tgz`): 17 | 18 | ```sh 19 | ./run-builder.sh 20 | ``` 21 | 22 | ### Side notes! 23 | 24 | Use an AWS big machine with some cores(need to update the j flag in ./run-builder.sh) and a lot of memory. I used a 25 | r3.4xlarge with 16 cores and 123GB of memory. It took about 1 hours to build. 26 | 27 | Remember to setup git and ssh keys on the machine you are building on. The build script will clone the mongodb repo and 28 | you will need to be able to do that. 29 | 30 | at the end of the script it will open the /build/install/bin directory and you will see a mongod and mongo or mongos 31 | binary, that is the one that you strip and ship. the two last lines of run-builder.sh will do that for you. 32 | 33 | Having your tarball you should create a git tag: 34 | 35 | ```sh 36 | git tag -a v4.2.0 -m "MongoDB 4.2.0" 37 | git push origin 38 | ``` 39 | 40 | Normally you will not commit your tarball to git. You have two options: 41 | 42 | create a branch and commit your tarball to that branch, create a PR and download the tarball from the PR and update the release tag. 43 | 44 | or you can send to an S3 and download it from there and update the tag with the tarball. 45 | 46 | If you have a big enough machine you can do it in your local machine. 47 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | cd /mongodb 5 | 6 | python3 -m pip install -r etc/pip/compile-requirements.txt 7 | python3 -m pip install requirements_parser jsonschema memory_profiler puremagic networkx cxxfilt 8 | 9 | export GIT_PYTHON_REFRESH=quiet 10 | 11 | ./buildscripts/scons.py \ 12 | install-core \ 13 | -j 20 \ 14 | LINKFLAGS='-static-libstdc++' \ 15 | --linker=gold 16 | 17 | cd build/install/bin 18 | strip mongos mongod 19 | -------------------------------------------------------------------------------- /run-builder.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | MONGODB_VERSION='7.0.5' 5 | SRC="mongodb-src-r$MONGODB_VERSION" 6 | TARGET="mongodb-linux-x86_64-${MONGODB_VERSION}" 7 | BIN="$TARGET/bin" 8 | 9 | [ ! -d $SRC ] && curl "https://fastdl.mongodb.org/src/$SRC.tar.gz" | tar -xz 10 | docker run --memory=58g --rm -it -v $(pwd)/$SRC:/mongodb mongodb-builder 11 | mkdir -p $BIN 12 | sudo mv "$SRC/build/install/bin/mongos" "$SRC/build/install/bin/mongod" $BIN 13 | sudo tar -czf "$TARGET.tgz" $TARGET 14 | --------------------------------------------------------------------------------