Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GODRIVER-2989 A Dockerfile for local development #1381

Merged
merged 54 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
668d8ae
GODRIVER-2924 Set up coverage reporting
blink1073 Sep 13, 2023
16ac3d6
wip
blink1073 Sep 13, 2023
3cc28f4
Quick update for api changes report. (#1384)
qingyang-hu Sep 15, 2023
5e3f22e
Make it configurable and add docs
blink1073 Sep 17, 2023
83c6c59
Merge branch 'v1' of github.com:mongodb/mongo-go-driver into GODRIVER…
blink1073 Sep 18, 2023
467dc08
GODRIVER-2981 [master] API comment doesn't work when job approver isn…
blink1073 Sep 19, 2023
4b0c121
GODRIVER-2986 [master] Resolve failures in Race Detector Test (#1392)
blink1073 Sep 19, 2023
b6a82ec
Update docs/CONTRIBUTING.md
blink1073 Sep 20, 2023
2a34143
Update docs/CONTRIBUTING.md
blink1073 Sep 20, 2023
5736345
Update docs/CONTRIBUTING.md
blink1073 Sep 20, 2023
53d36e5
address review
blink1073 Sep 20, 2023
78937fe
add docker test
blink1073 Sep 21, 2023
0437547
run on ubuntu
blink1073 Sep 21, 2023
3cd44f5
remove interactive flag
blink1073 Sep 21, 2023
962ff45
use podman
blink1073 Sep 21, 2023
26928a0
try on ubuntu 20
blink1073 Sep 21, 2023
5dcedbd
maybe fixed
blink1073 Sep 21, 2023
e46751d
skip a test
blink1073 Sep 21, 2023
461bd3c
use dockerfile from drivers-evergreen-tools
blink1073 Sep 22, 2023
0a17269
try again
blink1073 Sep 22, 2023
92ddc6d
clean up and add platform support
blink1073 Sep 23, 2023
a91a6ff
improve handling of libmongocrypt
blink1073 Sep 25, 2023
ee0738c
Merge branch 'v1' into GODRIVER-2924
blink1073 Sep 25, 2023
988dbcb
fix selector
blink1073 Sep 25, 2023
d38fe78
fix windows handling
blink1073 Sep 25, 2023
fd63e77
fix windows handling
blink1073 Sep 25, 2023
563763a
fix install dir
blink1073 Sep 25, 2023
d8f19ab
GODRIVER-2906 [master] Add container Env to Handshake. (#1397)
blink1073 Sep 25, 2023
738d3bb
GODRIVER-2859 [master] Add search index management helpers (#1396)
blink1073 Sep 25, 2023
a3c8def
Remove redundant nil check in `HasErrorLabel` (#1369)
Juneezee Sep 25, 2023
3e34fa3
GODRIVER-2690 Set minimum supported Go version to 1.18 in Go Driver v…
prestonvasquez Sep 25, 2023
ea3d739
try with this entry point
blink1073 Sep 26, 2023
8117ee1
handle crypt
blink1073 Sep 26, 2023
7bd711a
handle CRYPT_SHARED_LIB_PATH
blink1073 Sep 26, 2023
1100ecc
try another skip
blink1073 Sep 26, 2023
4c8b29e
try another skip
blink1073 Sep 26, 2023
c9a026b
fix binary path handling
blink1073 Sep 26, 2023
b02e519
GODRIVER-2982 [master] Add PR build tags. (#1401)
blink1073 Sep 27, 2023
cd3c699
GODRIVER-2955 [master] Add user-facing network compression documentat…
blink1073 Sep 28, 2023
9171dca
Merge branch 'master' of github.com:mongodb/mongo-go-driver into GODR…
blink1073 Oct 3, 2023
a3d3878
Use source branch
blink1073 Oct 3, 2023
3dcc04b
try with alpha version
blink1073 Oct 11, 2023
8c5d62a
try reverting behavior
blink1073 Oct 11, 2023
a5e07a9
whoops
blink1073 Oct 11, 2023
8f0bc14
try with final release
blink1073 Oct 11, 2023
c032558
try this approach
blink1073 Oct 11, 2023
d7928f2
remove redundant code
blink1073 Oct 11, 2023
6c73a2b
Revert "Merge branch 'master' of github.com:mongodb/mongo-go-driver i…
blink1073 Oct 11, 2023
ca67293
Merge branch 'v1' of github.com:mongodb/mongo-go-driver into GODRIVER…
blink1073 Oct 11, 2023
45ffaec
remove gnupg
blink1073 Oct 11, 2023
374d492
fix path handling
blink1073 Oct 11, 2023
aa0049b
try direct approach
blink1073 Oct 11, 2023
c87a9f5
try again
blink1073 Oct 11, 2023
eb9aed5
cleanup
blink1073 Oct 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ set -o errexit

export GOPATH=$(dirname $(dirname $(dirname `pwd`)))
export GOCACHE="$(pwd)/.cache"
export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
export DRIVERS_TOOLS=${DRIVERS_TOOLS:-""}

if [ -z $DRIVERS_TOOLS ]; then
export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
fi

if [ "Windows_NT" = "$OS" ]; then
export GOPATH=$(cygpath -m $GOPATH)
Expand All @@ -14,6 +18,7 @@ fi

export GOROOT="${GOROOT}"
export PATH="${GOROOT}/bin:${GCC_PATH}:$GOPATH/bin:$PATH"
export PATH="$DRIVERS_TOOLS/mongodb/bin:$PATH"
export PROJECT="${project}"
export PKG_CONFIG_PATH=$(pwd)/install/libmongocrypt/lib64/pkgconfig:$(pwd)/install/mongo-c-driver/lib/pkgconfig
export LD_LIBRARY_PATH=$(pwd)/install/libmongocrypt/lib64
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ perf
**mongocryptd.pid
*.test
.DS_Store
install
main.so
test.suite

# AWS SAM-generated files
internal/test/faas/awslambda/.aws-sam
Expand Down
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM ubuntu:22.04

RUN apt-get -qq update && apt-get -qqy -o DPkg::Lock::Timeout=-1 install --no-install-recommends \
git \
ca-certificates \
curl \
wget \
sudo \
gnupg \
python3 \
python3.10-venv \
build-essential \
golang-go \
pkg-config \
libssl-dev \
make \
lsof \
net-tools \
&& rm -rf /var/lib/apt/lists/*

RUN export LIBMONGOCRYPT_TAG="1.8.0-alpha1" && \
matthewdale marked this conversation as resolved.
Show resolved Hide resolved
cd $HOME && \
git clone https://github.com/mongodb/libmongocrypt --depth=1 --branch $LIBMONGOCRYPT_TAG && \
PKG_CONFIG_PATH=$HOME/install/libmongocrypt/lib/pkgconfig:$HOME/install/mongo-c-driver/lib/pkgconfig \
LD_LIBRARY_PATH=$HOME/install/libmongocrypt/lib \
./libmongocrypt/.evergreen/compile.sh

COPY ./etc/docker_entry.sh /root/docker_entry.sh

ENTRYPOINT ["/bin/bash", "/root/docker_entry.sh"]
13 changes: 13 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ The usage of host.docker.internal comes from the [Docker networking documentatio

There is currently no arm64 support for the go1.x runtime, see [here](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html). Known issues running on linux/arm64 include the inability to network with the localhost from the public.ecr.aws/lambda/go Docker image.

### Testing in Docker

We have a ``Dockerfile`` and supporting files to be used for local testing in a Linux environment.
Ensure ``docker`` is installed and running, and then run:
blink1073 marked this conversation as resolved.
Show resolved Hide resolved

```bash
bash etc/run_docker.sh
```

The script takes an optional argument for the ``MAKEFILE_TARGET`` and allows for some environment variable overrides.
The docker container will have the required binaries, including libmongocrypt.
blink1073 marked this conversation as resolved.
Show resolved Hide resolved
The entry script starts a mongodb topology, and then executes the desired ``MAKEFILE_TARGET``.
blink1073 marked this conversation as resolved.
Show resolved Hide resolved

matthewdale marked this conversation as resolved.
Show resolved Hide resolved
## Talk To Us

If you want to work on the driver, write documentation, or have questions/complaints, please reach out to us either via [MongoDB Community Forums](https://community.mongodb.com/tags/c/drivers-odms-connectors/7/go-driver) or by creating a Question issue in [Jira](https://jira.mongodb.org/secure/CreateIssue!default.jspa).
29 changes: 29 additions & 0 deletions etc/docker_entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
#
# Entry point for Dockerfile for launching a server and running a go test.
#
set -eux

# Handle env variables.
export DRIVERS_TOOLS=$HOME/drivers-evergreen-tools
export PROJECT_ORCHESTRATION_HOME=$DRIVERS_TOOLS/.evergreen/orchestration
export MONGO_ORCHESTRATION_HOME=$HOME

# Clone DRIVERS_TOOLS if necessary.
if [ ! -d $DRIVERS_TOOLS ]; then
git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
fi

# Disable ipv6.
sed -i "s/\"ipv6\": true,/\"ipv6\": false,/g" $PROJECT_ORCHESTRATION_HOME/configs/${TOPOLOGY}s/$ORCHESTRATION_FILE
matthewdale marked this conversation as resolved.
Show resolved Hide resolved

# Start the server.
bash $DRIVERS_TOOLS/.evergreen/run-orchestration.sh

# Prep files.
cd /src
rm -f test.suite
cp -r $HOME/install ./install

# Run the test.
bash ./.evergreen/run-tests.sh
21 changes: 21 additions & 0 deletions etc/run_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
#
# Script to run a test suite in docker locally
set -eux
docker build -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"
docker run --rm -v "`pwd`:/src" $ENV -it go-test
tail test.suite
Loading