diff --git a/.evergreen/auth_oidc/Dockerfile b/.evergreen/auth_oidc/Dockerfile index 657b5d1a..ab652279 100644 --- a/.evergreen/auth_oidc/Dockerfile +++ b/.evergreen/auth_oidc/Dockerfile @@ -1,6 +1,10 @@ FROM drivers-evergreen-tools -COPY ./docker_entry.sh /root/docker_entry.sh -COPY ./docker_entry_base.sh /root/docker_entry_base.sh +COPY ./.evergreen/auth_oidc/docker_entry.sh /root/docker_entry.sh +COPY ./.evergreen/auth_oidc/docker_entry_base.sh /root/docker_entry_base.sh ENV TOPOLOGY=replica_set +ENV DRIVERS_TOOLS=/root/drivers-tools +ENV MONGO_ORCHESTRATION_HOME=/root/drivers-tools/.evergreen/orchestration +ENV MONGODB_BINARIES=/root/drivers-tools/mongodb/bin +ENV DOCKER_RUNNING=true diff --git a/.evergreen/auth_oidc/start_local_server.sh b/.evergreen/auth_oidc/start_local_server.sh index 96f6e1e0..b044f5e3 100755 --- a/.evergreen/auth_oidc/start_local_server.sh +++ b/.evergreen/auth_oidc/start_local_server.sh @@ -27,7 +27,6 @@ EOF ENTRYPOINT=${ENTRYPOINT:-/root/docker_entry.sh} USE_TTY="" -VOL="-v ${DRIVERS_TOOLS}:/root/drivers-evergreen-tools" AWS_PROFILE=${AWS_PROFILE:-""} if [ -z "$AWS_PROFILE" ]; then @@ -37,18 +36,32 @@ if [ -z "$AWS_PROFILE" ]; then fi ENV="-e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" ENV="$ENV -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY" + VOL="" else ENV="-e AWS_PROFILE=$AWS_PROFILE" - VOL="$VOL -v $HOME/.aws:/root/.aws" + VOL="-v $HOME/.aws:/root/.aws" fi test -t 1 && USE_TTY="-t" echo "Drivers tools: $DRIVERS_TOOLS" -pushd ../docker -rm -rf ./ubuntu20.04/mongodb -rm -rf ./ubuntu20.04/orchestration -docker build -t drivers-evergreen-tools ./ubuntu20.04 + +if command -v podman &> /dev/null; then + DOCKER="podman --storage-opt ignore_chown_errors=true" +else + DOCKER=docker +fi +if [ -n "${DOCKER_COMMAND:-}" ]; then + DOCKER=$DOCKER_COMMAND +fi + +# Build from the root directory so we can include files. +pushd $DRIVERS_TOOLS +PLATFORM="--platform linux/amd64" +cp .gitignore .dockerignore +USER="--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)" +$DOCKER build $PLATFORM -t drivers-evergreen-tools -f $SCRIPT_DIR/../docker/ubuntu20.04/Dockerfile $USER . +$DOCKER build $PLATFORM -t oidc-test $VOL -f $SCRIPT_DIR/Dockerfile $USER . popd -docker build -t oidc-test . -docker run --rm -i $USE_TTY $VOL $ENV -p 27017:27017 -p 27018:27018 oidc-test $ENTRYPOINT + +$DOCKER run --rm -i $USE_TTY $ENV -p 27017:27017 -p 27018:27018 oidc-test $ENTRYPOINT diff --git a/.evergreen/docker/run-client.sh b/.evergreen/docker/run-client.sh index 613e99a8..23ec53b1 100755 --- a/.evergreen/docker/run-client.sh +++ b/.evergreen/docker/run-client.sh @@ -6,10 +6,18 @@ set -eu # Docker related variables. -IMAGE=${TARGET_IMAGE:-ubuntu20.04} PLATFORM=${DOCKER_PLATFORM:-} # e.g. --platform linux/amd64 +if command -v podman &> /dev/null; then + DOCKER="podman --storage-opt ignore_chown_errors=true" +else + DOCKER=docker +fi +if [ -n "${DOCKER_COMMAND:-}" ]; then + DOCKER=$DOCKER_COMMAND +fi + # Mongo orchestration related variables. MONGODB_VERSION=${MONGODB_VERSION:-latest} TOPOLOGY=${TOPOLOGY:-replica_set} @@ -18,19 +26,18 @@ SKIP_CRYPT_SHARED_LIB=${SKIP_CRYPT_SHARED_LIB:-false} AUTH=${AUTH:-""} SSL=${SSL:-""} -# Internal variables. -ROOT_DRIVERS_TOOLS=/root/drivers-evergeen-tools -MONGODB_BINARIES="ROOT_DRIVERS_TOOLS/.evergreen/docker/$IMAGE/mongodb/bin" +CONT_DRIVERS_TOOLS=/root/drivers-tools # Build up the arguments. ARGS="$PLATFORM --rm -i" ARGS+=" -e MONGODB_VERSION=$MONGODB_VERSION -e TOPOLOGY=$TOPOLOGY" ARGS+=" -e SSL=$SSL -e AUTH=$AUTH" -ARGS+=" -e MONGODB_BINARIES=$MONGODB_BINARIES" -ARGS+=" -e CRYPT_SHARED_LIB_PATH=$MONGODB_BINARIES/mongosh_crypt_v1.so" +ARGS+=" -e MONGO_ORCHESTRATION_HOME=$CONT_DRIVERS_TOOLS/.evergreen/orchestration" +ARGS+=" -e MONGODB_BINARIES=$CONT_DRIVERS_TOOLS/mongodb/bin" +ARGS+=" -e DOCKER_RUNNING=true" +ARGS+=" -e CRYPT_SHARED_LIB_PATH=$CONT_DRIVERS_TOOLS/mongosh_crypt_v1.so" ARGS+=" -e ORCHESTRATION_FILE=$ORCHESTRATION_FILE" ARGS+=" -e SKIP_CRYPT_SHARED_LIB=$SKIP_CRYPT_SHARED_LIB" -ARGS+=" -e DRIVERS_TOOLS=$ROOT_DRIVERS_TOOLS" # Ensure host.docker.internal is available on MacOS. if [ "$(uname -s)" = "Darwin" ]; then @@ -47,7 +54,7 @@ test -t 1 && ARGS+=" -t" # Map the cwd to /src and map in DRIVERS_TOOLS. ARGS+=" -v `pwd`:/src" -ARGS+=" -v $DRIVERS_TOOLS:/root/drivers-evergreen-tools" +ARGS+=" -v $DRIVERS_TOOLS:$CONT_DRIVERS_TOOLS" # Launch client docker container. -docker run $ARGS "$@" +$DOCKER run $ARGS "$@" diff --git a/.evergreen/docker/run-server.sh b/.evergreen/docker/run-server.sh index 3adcc72d..6c78e686 100755 --- a/.evergreen/docker/run-server.sh +++ b/.evergreen/docker/run-server.sh @@ -19,7 +19,7 @@ if [[ -z $PLATFORM && -n $ARCH ]]; then fi if command -v podman &> /dev/null; then - DOCKER=podman + DOCKER="podman --storage-opt ignore_chown_errors=true" else DOCKER=docker fi @@ -27,15 +27,12 @@ if [ -n "${DOCKER_COMMAND:-}" ]; then DOCKER=$DOCKER_COMMAND fi -pushd $SCRIPT_DIR +# Build from the root directory so we can include files. +pushd $DRIVERS_TOOLS +cp .gitignore .dockerignore USER="--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)" -$DOCKER build $PLATFORM -t $NAME $USER $IMAGE +$DOCKER build $PLATFORM -t $NAME -f $SCRIPT_DIR/$IMAGE/Dockerfile $USER . popd -pushd $DRIVERS_TOOLS - -# Remove existing mongodb and orchestration files -rm -rf $SCRIPT_DIR/$IMAGE/mongodb -rm -rf $SCRIPT_DIR/$IMAGE/orchestration # Handle environment variables. AUTH=${AUTH:-noauth} @@ -77,10 +74,5 @@ fi # If there is a tty, add the -t arg. test -t 1 && ARGS+=" -t" -# Map in the DRIVERS_TOOLS directory. -ARGS+=" -v `pwd`:/root/drivers-evergreen-tools" - # Launch server container. $DOCKER run $ARGS $NAME $ENTRYPOINT - -popd diff --git a/.evergreen/docker/ubuntu18.04/Dockerfile b/.evergreen/docker/ubuntu18.04/Dockerfile index 8ee056cb..1cfed659 100644 --- a/.evergreen/docker/ubuntu18.04/Dockerfile +++ b/.evergreen/docker/ubuntu18.04/Dockerfile @@ -1,4 +1,4 @@ -FROM artifactory.corp.mongodb.com/dockerhub/ubuntu:18.04 +FROM ubuntu:18.04 RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get -qq update && apt-get -qq -y install --no-install-recommends \ @@ -46,12 +46,10 @@ RUN export DEBIAN_FRONTEND=noninteractive \ 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/drivers-evergreen-tools/.evergreen/docker/ubuntu18.04/mongodb/bin -ENV MONGO_ORCHESTRATION_HOME=/root/drivers-evergreen-tools/.evergreen/docker/ubuntu18.04/orchestration +ENV DRIVERS_TOOLS=/root/drivers-tools +ENV MONGO_ORCHESTRATION_HOME=/root/drivers-tools/.evergreen/orchestration +ENV MONGODB_BINARIES=/root/drivers-tools/mongodb/bin 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 +COPY . /root/drivers-tools +COPY .evergreen/docker/ubuntu18.04/*.sh /root diff --git a/.evergreen/docker/ubuntu18.04/base-entrypoint.sh b/.evergreen/docker/ubuntu18.04/base-entrypoint.sh index 2404dfa7..6008e277 100755 --- a/.evergreen/docker/ubuntu18.04/base-entrypoint.sh +++ b/.evergreen/docker/ubuntu18.04/base-entrypoint.sh @@ -5,10 +5,4 @@ set -eu cd $DRIVERS_TOOLS make run-server -# Preserve host permissions of files we have created. -cd $DRIVERS_TOOLS -files=(results.json uri.txt mongo_crypt_v1.so mo-expansion.yml) -chown --reference=action.yml "${files[@]}" -chmod --reference=action.yml "${files[@]}" - echo "Server started!" diff --git a/.evergreen/docker/ubuntu20.04/Dockerfile b/.evergreen/docker/ubuntu20.04/Dockerfile index 2c9bf854..7ab5fcee 100644 --- a/.evergreen/docker/ubuntu20.04/Dockerfile +++ b/.evergreen/docker/ubuntu20.04/Dockerfile @@ -1,4 +1,4 @@ -FROM artifactory.corp.mongodb.com/dockerhub/ubuntu:20.04 +FROM ubuntu:20.04 RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get -qq update && apt-get -qq -y install --no-install-recommends \ @@ -21,12 +21,10 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ 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/drivers-evergreen-tools/.evergreen/docker/ubuntu20.04/mongodb/bin -ENV MONGO_ORCHESTRATION_HOME=/root/drivers-evergreen-tools/.evergreen/docker/ubuntu20.04/orchestration +ENV DRIVERS_TOOLS=/root/drivers-tools +ENV MONGO_ORCHESTRATION_HOME=/root/drivers-tools/.evergreen/orchestration +ENV MONGODB_BINARIES=/root/drivers-tools/mongodb/bin 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 +COPY . /root/drivers-tools +COPY .evergreen/docker/ubuntu20.04/*.sh /root diff --git a/.evergreen/docker/ubuntu20.04/base-entrypoint.sh b/.evergreen/docker/ubuntu20.04/base-entrypoint.sh index 2404dfa7..6008e277 100755 --- a/.evergreen/docker/ubuntu20.04/base-entrypoint.sh +++ b/.evergreen/docker/ubuntu20.04/base-entrypoint.sh @@ -5,10 +5,4 @@ set -eu cd $DRIVERS_TOOLS make run-server -# Preserve host permissions of files we have created. -cd $DRIVERS_TOOLS -files=(results.json uri.txt mongo_crypt_v1.so mo-expansion.yml) -chown --reference=action.yml "${files[@]}" -chmod --reference=action.yml "${files[@]}" - echo "Server started!" diff --git a/.gitignore b/.gitignore index bed44137..f716390b 100644 --- a/.gitignore +++ b/.gitignore @@ -124,6 +124,7 @@ mo-expansion.sh .evergreen/socks5srv .evergreen/mongodl .evergreen/mongosh-dl +.dockerignore # Azure functions. .python_packages/