-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
48 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,29 @@ Have Docker running on your machine. You can download and install from: https:// | |
|
||
In order to execute the code example, you need to specify `MONGODB_URI` environment variable to connect to a MongoDB cluster. If you don't have any you can create one by signing up [MongoDB Atlas Free-tier M0](https://docs.atlas.mongodb.com/getting-started/). | ||
|
||
## Build Steps | ||
|
||
## Execution Steps | ||
|
||
1. Build Docker image with a tag name. Within the top level directory execute: | ||
``` | ||
docker build . -t start-cxx | ||
``` | ||
This will build a docker image with a tag name `start-cxx`. | ||
|
||
2. Execute the helper shell script followed by the MongoDB URI that you would like to connect to. | ||
``` | ||
./get-started.sh "mongodb+srv://usr:[email protected]/dbname?retryWrites=true" | ||
``` | ||
To use a different driver version, specify the driver version after the MongoDB URI. For example: | ||
``` | ||
./get-started.sh "mongodb+srv://usr:[email protected]/dbname?retryWrites=true" 3.6.0 | ||
``` | ||
## Alternative Execution Steps (without helper) | ||
#### Build Steps | ||
1. Build Docker image with a tag name. Within this directory execute: | ||
* To use the default driver version and specify `MONGODB_URI`: | ||
|
@@ -32,12 +54,12 @@ In order to execute the code example, you need to specify `MONGODB_URI` environm | |
2. Run the Docker image by executing: | ||
``` | ||
docker run --tty --interactive --hostname cxx start-cxx | ||
docker run --tty --interactive --hostname cxx start-cxx bash | ||
``` | ||
The command above will run a `start-cxx` tagged Docker image. Sets the hostname as `cxx`. | ||
## Execution Steps | ||
#### Execution | ||
1. Compile and execute the code example by following below steps: | ||
* `c++ --std=c++11 getstarted.cpp -o getstarted $(pkg-config --cflags --libs libmongocxx)` | ||
|
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 @@ | ||
#!/bin/bash | ||
MONGODB_URI=${1} | ||
if [ -z ${MONGODB_URI} ] | ||
then | ||
read -p "MONGODB URI (Required): " MONGODB_URI | ||
fi | ||
|
||
DRIVER_VERSION=${2:-3.6.2} | ||
echo "Executing ... " | ||
docker run --rm -e MONGODB_URI=${MONGODB_URI} \ | ||
-v "$(pwd)":/workspace \ | ||
-w /workspace/cxx start-cxx \ | ||
"c++ --std=c++11 ./getstarted.cpp -o getstarted -I/usr/local/include/mongocxx/v_noabi -I/usr/local/include/bsoncxx/v_noabi -L/usr/local/lib -lmongocxx -lbsoncxx; \ | ||
./getstarted" |