-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GODRIVER-2989 A Dockerfile for local development (#1381)
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com> Co-authored-by: Qingyang Hu <103950869+qingyang-hu@users.noreply.github.com> Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com> Co-authored-by: Matt Dale <9760375+matthewdale@users.noreply.github.com> Co-authored-by: Eng Zer Jun <engzerjun@gmail.com> (cherry picked from commit 6d7a981)
- Loading branch information
Showing
11 changed files
with
200 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Dockerfile for Go Driver local development. | ||
|
||
# Build libmongocrypt in a separate build stage. | ||
FROM ubuntu:20.04 as libmongocrypt | ||
|
||
RUN apt-get -qq update && \ | ||
apt-get -qqy install --no-install-recommends \ | ||
git \ | ||
ca-certificates \ | ||
curl \ | ||
build-essential \ | ||
libssl-dev \ | ||
python | ||
|
||
COPY etc/install-libmongocrypt.sh /root/install-libmongocrypt.sh | ||
RUN cd /root && bash ./install-libmongocrypt.sh | ||
|
||
|
||
# Inherit from the drivers-evergreen-tools image and copy in the files | ||
# from the libmongocrypt build stage. | ||
FROM drivers-evergreen-tools | ||
|
||
RUN export DEBIAN_FRONTEND=noninteractive && \ | ||
export TZ=Etc/UTC && \ | ||
apt-get -qq update && \ | ||
apt-get -qqy install --no-install-recommends \ | ||
pkg-config \ | ||
tzdata \ | ||
gpg \ | ||
apt-utils \ | ||
make && \ | ||
apt-add-repository ppa:longsleep/golang-backports && \ | ||
apt-get -qq update && \ | ||
apt-get -qqy install --no-install-recommends golang-go && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
COPY ./etc/docker_entry.sh /root/docker_entry.sh | ||
|
||
COPY --from=libmongocrypt /root/install /root/install | ||
|
||
ENTRYPOINT ["/bin/bash", "/root/docker_entry.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Entry point for Dockerfile for launching a server and running a go test. | ||
# | ||
set -eux | ||
|
||
# Start the server. | ||
bash /root/base-entrypoint.sh | ||
source $DRIVERS_TOOLS/.evergreen/mo-expansion.sh | ||
|
||
# Prep files. | ||
cd /src | ||
rm -f test.suite | ||
cp -r $HOME/install ./install | ||
export PATH="$MONGODB_BINARIES:$PATH" | ||
|
||
# Run the test. | ||
bash ./.evergreen/run-tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
# install libmongocrypt | ||
# This script installs libmongocrypt into an "install" directory. | ||
set -eux | ||
|
||
LIBMONGOCRYPT_TAG="1.8.2" | ||
|
||
# Install libmongocrypt based on OS. | ||
if [ "Windows_NT" = "${OS:-}" ]; then | ||
mkdir -p c:/libmongocrypt/include | ||
mkdir -p c:/libmongocrypt/bin | ||
echo "fetching build for Windows ... begin" | ||
mkdir libmongocrypt-all | ||
cd libmongocrypt-all | ||
# The following URL is published from the upload-all task in the libmongocrypt Evergreen project. | ||
curl https://mciuploads.s3.amazonaws.com/libmongocrypt/all/$LIBMONGOCRYPT_TAG/libmongocrypt-all.tar.gz -o libmongocrypt-all.tar.gz | ||
tar -xf libmongocrypt-all.tar.gz | ||
cd .. | ||
cp libmongocrypt-all/windows-test/bin/mongocrypt.dll c:/libmongocrypt/bin | ||
cp libmongocrypt-all/windows-test/include/mongocrypt/*.h c:/libmongocrypt/include | ||
|
||
rm -rf libmongocrypt-all | ||
echo "fetching build for Windows ... end" | ||
else | ||
rm -rf libmongocrypt | ||
git clone https://github.com/mongodb/libmongocrypt --depth=1 --branch $LIBMONGOCRYPT_TAG 2> /dev/null | ||
if ! ( ./libmongocrypt/.evergreen/compile.sh >| output.txt 2>&1 ); then | ||
cat output.txt 1>&2 | ||
exit 1 | ||
fi | ||
mv output.txt install | ||
rm -rf libmongocrypt | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Script to run a test suite in docker locally | ||
set -eux | ||
|
||
if [ -z "$DRIVERS_TOOLS" ]; then | ||
echo "Please set DRIVERS_TOOLS env variable." | ||
exit 1 | ||
fi | ||
PLATFORM=${DOCKER_PLATFORM:-} | ||
|
||
pushd $DRIVERS_TOOLS/.evergreen/docker/ubuntu20.04 | ||
docker build $PLATFORM -t drivers-evergreen-tools . | ||
popd | ||
docker build $PLATFORM -t go-test . | ||
|
||
# Handle environment variables and optional positional arg for the makefile target. | ||
|
||
MAKEFILE_TARGET=${1:-evg-test-versioned-api} | ||
MONGODB_VERSION=${MONGODB_VERSION:-latest} | ||
TOPOLOGY=${TOPOLOGY:-replica_set} | ||
ORCHESTRATION_FILE=${ORCHESTRATION_FILE:-basic.json} | ||
AUTH=${AUTH:-""} | ||
SSL=${SSL:=""} | ||
GO_BUILD_TAGS=${GO_BUILD_TAGS:-""} | ||
|
||
ENV="-e MONGODB_VERSION=$MONGODB_VERSION -e TOPOLOGY=$TOPOLOGY" | ||
ENV="$ENV -e MAKEFILE_TARGET=$MAKEFILE_TARGET -e AUTH=$AUTH" | ||
ENV="$ENV -e ORCHESTRATION_FILE=$ORCHESTRATION_FILE -e SSL=$SSL" | ||
ENV="$ENV -e GO_BUILD_TAGS=$GO_BUILD_TAGS" | ||
|
||
VOL="-v `pwd`:/src" | ||
VOL="$VOL -v $DRIVERS_TOOLS:/root/drivers-evergreen-tools" | ||
USE_TTY="" | ||
test -t 1 && USE_TTY="-t" | ||
|
||
docker run $PLATFORM --rm $VOL $ENV -i $USE_TTY go-test | ||
if [ -f "test.suite" ]; then | ||
tail test.suite | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters