-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GODRIVER-2924 Add docker file support (#352)
* GODRIVER-2924 Add docker file support * add evg test * fix syntax * add to build variant * cleanup * fix orch file * remove interactive flag * clean up and add oidc test * fix handling of tty * update readme * enforce bash * fix handling of python3 * try again * cleanup * Update .evergreen/run-orchestration.sh Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com> * address review * clean up file permissions and test results * use explicit binary root * move crypt_shared into container * fix echo * fix test file handling * try again * try again * more oidc debug * fix syntax * fix unbound * fix script * more oidc fixes * more oidc fixes * update permissions handling * remove popd * fix entry point usage * better test * add missing file * Update .evergreen/auth_oidc/start_local_server.sh Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com> * Update .evergreen/start-orchestration.sh Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com> * Update .evergreen/run-orchestration.sh Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com> * Update .evergreen/docker/ubuntu20.04/base-entrypoint.sh Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com> * address review * fix mo-expansion.sh * syntax * fix test entry point * Update .evergreen/config.yml Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com> * fix handling of python binary * Update .evergreen/run-orchestration.sh Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com> * Update .evergreen/run-orchestration.sh Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com> --------- Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
- Loading branch information
1 parent
80a9077
commit f825f86
Showing
16 changed files
with
300 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,6 @@ | ||
FROM ubuntu:20.04 | ||
FROM drivers-evergreen-tools | ||
|
||
RUN apt-get -qq update && apt-get -qqy -o DPkg::Lock::Timeout=-1 install --no-install-recommends \ | ||
git \ | ||
ca-certificates \ | ||
curl \ | ||
wget \ | ||
sudo \ | ||
gnupg \ | ||
python \ | ||
python3 \ | ||
python3-virtualenv \ | ||
lsof \ | ||
libsnmp35 \ | ||
net-tools \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
COPY ./docker_entry.sh /root/docker_entry.sh | ||
COPY ./docker_entry_base.sh /root/docker_entry_base.sh | ||
|
||
COPY ./docker_entry.sh /home/root/docker_entry.sh | ||
|
||
ENTRYPOINT ["/bin/bash", "/home/root/docker_entry.sh"] | ||
ENV TOPOLOGY=replica_set |
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,20 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Entry point for Dockerfile for launching an oidc-enabled server. | ||
# | ||
set -eu | ||
export ORCHESTRATION_FILE=auth-oidc.json | ||
|
||
trap "rm -rf authoidcvenv" EXIT HUP | ||
|
||
rm -f $DRIVERS_TOOLS/results.json | ||
cd $DRIVERS_TOOLS/.evergreen/auth_oidc | ||
rm -rf authoidcvenv | ||
. ./activate-authoidcvenv.sh | ||
python oidc_write_orchestration.py | ||
|
||
bash /root/base-entrypoint.sh | ||
|
||
$MONGODB_BINARIES/mongosh $DRIVERS_TOOLS/.evergreen/auth_oidc/setup_oidc.js | ||
|
||
echo "Server started!" |
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,43 @@ | ||
# Drivers Evergreen Tools Dockerfile | ||
|
||
The ``Dockerfile`` and scripts in the subdirector(ies) serve dual purposes. | ||
|
||
- Run a local server in docker container. | ||
- Extend and run a driver test in a docker container. | ||
|
||
You will need Docker (or podman aliased to Docker) installed and running | ||
locally. | ||
|
||
# Run Local Server | ||
|
||
To run a local server, change to this directory and run: | ||
|
||
```bash | ||
bash ./run-local.sh | ||
``` | ||
|
||
This will build the docker image and run it with appropriate settings. | ||
Note that any of the environment variables used by `run-orchestration` | ||
will be passed through to the container. | ||
The appropriate port(s) will be exposed, allowing you to run local test against | ||
the running docker container. | ||
|
||
The default image can be overridden with `IMAGE``, and the entrypoint with `ENTRYPOINT`. | ||
To use a specific architecture, use `PLATFORM`, e.g. `--platform linux/amd64`. | ||
|
||
## Driver Testing in Docker | ||
|
||
To extend this image and run against a driver test suite, first build the | ||
image locally. | ||
|
||
```bash | ||
docker build -t drivers-evergreen-tools . | ||
``` | ||
|
||
Then, in your `Dockerfile`, use `FROM drivers-evergreen-tools`. | ||
|
||
When running your derived image, use `-v $DRIVERS_TOOLS:/root/drivers-evergreen-tools` | ||
to use the local checkout. | ||
|
||
In your entry point script, run `run-orchestration.sh` before running your test suite. | ||
Note that you will probably want to expose the environment variables as is done in `run-local.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,47 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Run a local MongoDB orchestration inside a docker container | ||
# | ||
set -eu | ||
|
||
NAME=drivers-evergreen-tools | ||
ENTRYPOINT=${ENTRYPOINT:-/root/local-entrypoint.sh} | ||
IMAGE=${TARGET_IMAGE:-ubuntu20.04} | ||
PLATFORM=${DOCKER_PLATFORM:-} | ||
# e.g. --platform linux/amd64 | ||
|
||
docker build $PLATFORM -t $NAME $IMAGE | ||
cd ../.. | ||
|
||
AUTH=${AUTH:-noauth} | ||
SSL=${SSL:-nossl} | ||
TOPOLOGY=${TOPOLOGY:-server} | ||
LOAD_BALANCER=${LOAD_BALANCER:-} | ||
STORAGE_ENGINE=${STORAGE_ENGINE:-} | ||
REQUIRE_API_VERSION=${REQUIRE_API_VERSION:-} | ||
DISABLE_TEST_COMMANDS=${DISABLE_TEST_COMMANDS:-} | ||
MONGODB_VERSION=${MONGODB_VERSION:-latest} | ||
MONGODB_DOWNLOAD_URL=${MONGODB_DOWNLOAD_URL:-} | ||
ORCHESTRATION_FILE=${ORCHESTRATION_FILE:-basic.json} | ||
|
||
ENV="-e MONGODB_VERSION=$MONGODB_VERSION" | ||
ENV+=" -e TOPOLOGY=$TOPOLOGY" | ||
ENV+=" -e AUTH=$AUTH" | ||
ENV+=" -e SSL=$SSL" | ||
ENV+=" -e ORCHESTRATION_FILE=$ORCHESTRATION_FILE" | ||
ENV+=" -e LOAD_BALANCER=$LOAD_BALANCER" | ||
ENV+=" -e STORAGE_ENGINE=$STORAGE_ENGINE" | ||
ENV+=" -e REQUIRE_API_VERSION=$REQUIRE_API_VERSION" | ||
ENV+=" -e DISABLE_TEST_COMMANDS=$DISABLE_TEST_COMMANDS" | ||
ENV+=" -e MONGODB_DOWNLOAD_URL=$MONGODB_DOWNLOAD_URL" | ||
|
||
if [ "$TOPOLOGY" == "server" ]; then | ||
PORT="-p 27017:2017" | ||
else | ||
PORT="-p 27017:2017 -p 27018:2018 -p 27019:2019" | ||
fi | ||
USE_TTY="" | ||
test -t 1 && USE_TTY="-t" | ||
VOL="-v `pwd`:/root/drivers-evergreen-tools" | ||
|
||
docker run $PLATFORM --rm $ENV $PORT $VOL -i $USE_TTY $NAME $ENTRYPOINT |
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 @@ | ||
FROM ubuntu:20.04 | ||
|
||
RUN export DEBIAN_FRONTEND=noninteractive && \ | ||
apt-get -qq update && apt-get -qqy install --no-install-recommends \ | ||
git \ | ||
ca-certificates \ | ||
curl \ | ||
wget \ | ||
sudo \ | ||
gnupg \ | ||
python \ | ||
python3 \ | ||
python3.8-venv \ | ||
lsof \ | ||
software-properties-common \ | ||
libsnmp35 \ | ||
net-tools \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ARG USER_ID | ||
ARG GROUP_ID | ||
|
||
ENV DRIVERS_TOOLS=/root/drivers-evergreen-tools | ||
ENV PROJECT_ORCHESTRATION_HOME=/root/drivers-evergreen-tools/.evergreen/orchestration | ||
ENV MONGODB_BINARIES=/root/mongodb/bin | ||
ENV MONGODB_BINARY_ROOT=/root | ||
ENV MONGO_ORCHESTRATION_HOME=/root | ||
ENV SKIP_LEGACY_SHELL=1 | ||
ENV DOCKER_RUNNING=true | ||
|
||
COPY ./local-entrypoint.sh /root/local-entrypoint.sh | ||
COPY ./base-entrypoint.sh /root/base-entrypoint.sh | ||
COPY ./test-entrypoint.sh /root/test-entrypoint.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,14 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
rm -f $DRIVERS_TOOLS/results.json | ||
cd $DRIVERS_TOOLS/.evergreen | ||
bash run-orchestration.sh | ||
|
||
# Preserve host permissions of files we have created. | ||
cd $DRIVERS_TOOLS | ||
files=(results.json uri.txt .evergreen/mongo_crypt_v1.so .evergreen/mo-expansion.yml) | ||
chown --reference=action.yml "${files[@]}" | ||
chmod --reference=action.yml "${files[@]}" | ||
|
||
echo "Server started!" |
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,5 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
bash /root/base-entrypoint.sh | ||
tail -f $MONGO_ORCHESTRATION_HOME/server.log |
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,7 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
bash /root/base-entrypoint.sh | ||
source $DRIVERS_TOOLS/.evergreen/mo-expansion.sh | ||
$MONGODB_BINARIES/mongosh --eval 'db' | ||
echo "Test complete!" |
Oops, something went wrong.