Skip to content

Commit dcf5f05

Browse files
GuanzhouSongCopilot
andcommitted
Correct installation and client connection instructions
Signed-off-by: Guanzhou Song <26541184+GuanzhouSong@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c5bd74a commit dcf5f05

4 files changed

Lines changed: 297 additions & 57 deletions

File tree

‎PACKAGE-INSTALL.md‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,10 @@ The current release publishes PostgreSQL 17 and 18. Install `documentdb-17` or
349349
## Upgrading an existing install
350350

351351
> **Warning:** In-place package upgrades from earlier releases are not supported yet. Use a
352-
> clean host, or remove the earlier packages and perform the
353-
> current fresh installation. Upgrading only `postgresql-N-documentdb` does not install the
354-
> gateway, tools, common payload, or `documentdb-N`.
352+
> clean host or a new, empty PostgreSQL instance for the current fresh installation.
353+
> Removing packages alone does not create a fresh database: package removal preserves PostgreSQL data and
354+
> in-database content, and a later setup run reuses an initialized data directory. Upgrading only
355+
> `postgresql-N-documentdb` does not install the gateway, tools, common payload, or `documentdb-N`.
355356
356357
For a later point release that uses the same multi-package layout, move the entire stack
357358
together. On a package-managed private PostgreSQL 18 instance:
@@ -453,9 +454,13 @@ ubuntu24.04-postgresql-18-documentdb_0.117-0_amd64.deb
453454
rhel9-postgresql18-documentdb-0.117.0-1.el9.x86_64.rpm
454455
```
455456

456-
Because the packages depend on each other, installing a downloaded meta package on its own
457-
fails with `Depends: documentdb-18 ... but it is not installable`. Pass the whole set to a
458-
single command, or just use the repository-backed install above.
457+
For a full stack, pass the five packages for the selected PostgreSQL major to one command:
458+
`documentdb-N`, the matching `postgresql-N-documentdb` / `postgresqlN-documentdb` extension,
459+
`documentdb-common`, `documentdb-gateway`, and `documentdb-postgresql-tools`. For PostgreSQL 18
460+
only, the optional `documentdb` meta package may be included; it selects `documentdb-18`.
461+
Local files resolve dependencies only against enabled repositories, so a package whose
462+
dependencies are not included still fails. Alternatively, use the repository-backed install
463+
above.
459464

460465
- GitHub Releases: https://github.com/documentdb/documentdb/releases
461466
- Release metadata: https://documentdb.io/packages/release-info.json

‎app/packages/page.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ type InstallMethod = "docker" | "packages";
2525
type PackageFamily = "apt" | "rpm";
2626

2727
const dockerCommand = `docker run -dt --name documentdb \\
28-
-p 10260:10260 \\
28+
-p 127.0.0.1:10260:10260 \\
2929
ghcr.io/documentdb/documentdb/documentdb-local:latest \\
30-
--username <YOUR_USERNAME> \\
31-
--password <YOUR_PASSWORD>`;
30+
--username '<YOUR_USERNAME>' \\
31+
--password '<YOUR_PASSWORD>'`;
3232

3333
const nextGuides = [
3434
{

‎app/services/articleService.ts‎

Lines changed: 97 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ Then start the container:
5050
docker run -dt --name documentdb \\
5151
-p 127.0.0.1:10260:10260 \\
5252
ghcr.io/documentdb/documentdb/documentdb-local:latest \\
53-
--username <YOUR_USERNAME> \\
54-
--password <YOUR_PASSWORD> \\
53+
--username '<YOUR_USERNAME>' \\
54+
--password '<YOUR_PASSWORD>' \\
5555
--init-data true
5656
\`\`\`
5757
@@ -90,8 +90,8 @@ Use \`mongosh\` to confirm authentication, TLS, and the gateway endpoint are wor
9090
9191
\`\`\`bash
9292
mongosh localhost:10260 \\
93-
-u <YOUR_USERNAME> \\
94-
-p <YOUR_PASSWORD> \\
93+
-u '<YOUR_USERNAME>' \\
94+
-p '<YOUR_PASSWORD>' \\
9595
--authenticationMechanism SCRAM-SHA-256 \\
9696
--tls \\
9797
--tlsAllowInvalidCertificates
@@ -220,7 +220,7 @@ Then install \`mongosh\`, which you need to talk to the endpoint:
220220
221221
\`\`\`bash
222222
# Ubuntu 24.04
223-
curl -fsSL https://pgp.mongodb.com/server-8.0.asc | sudo gpg --dearmor -o /usr/share/keyrings/mongodb.gpg
223+
curl -fsSL https://pgp.mongodb.com/server-8.0.asc | sudo gpg --dearmor --yes -o /usr/share/keyrings/mongodb.gpg
224224
echo "deb [signed-by=/usr/share/keyrings/mongodb.gpg] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list
225225
sudo apt update && sudo apt install -y mongodb-mongosh
226226
@@ -382,9 +382,11 @@ For an adopted instance, use the operator's existing PostgreSQL connection inste
382382
## Upgrading
383383
384384
> [!WARNING]
385-
> In-place package upgrades from earlier releases are not supported yet. Use a clean host,
386-
> or remove the earlier packages and perform the current
387-
> [fresh installation](/docs/getting-started/packages). Upgrading only
385+
> In-place package upgrades from earlier releases are not supported yet. Use a clean host
386+
> or a new, empty PostgreSQL instance and follow the current
387+
> [fresh installation](/docs/getting-started/packages). Removing packages alone does not
388+
> create a fresh database: package removal preserves PostgreSQL data and in-database content,
389+
> and a later setup run reuses an initialized data directory. Upgrading only
388390
> \`postgresql-N-documentdb\` does not install the gateway, tools, common payload, or
389391
> \`documentdb-N\`.
390392
@@ -609,7 +611,7 @@ Then continue with [Set up and connect](/docs/getting-started/packages#set-up-an
609611
If the target already has PostgreSQL, the PGDG extension dependencies (\`postgresql-N-cron\`, \`-pgvector\`, \`-postgis-3\`) and \`jq\`, you do not need a bundle:
610612
611613
- **Extension only, one file** — \`sudo apt install ./ubuntu24.04-postgresql-18-documentdb_0.117-0_amd64.deb\`. No gateway and no \`documentdb-setup\`.
612-
- **Full stack from the release assets** — pass all six files for your platform to a *single* \`apt install\` / \`dnf install\`. Local files resolve dependencies only against enabled repositories, so the meta package on its own fails with \`Depends: documentdb-18 ... but it is not installable\`.
614+
- **Full stack from the release assets** — pass the five packages for the selected PostgreSQL major to a *single* \`apt install\` / \`dnf install\`: \`documentdb-N\`, the matching \`postgresql-N-documentdb\` / \`postgresqlN-documentdb\` extension, \`documentdb-common\`, \`documentdb-gateway\`, and \`documentdb-postgresql-tools\`. For PostgreSQL 18 only, the optional \`documentdb\` meta package may be included; it selects \`documentdb-18\`. Local files resolve dependencies only against enabled repositories, so a package whose dependencies are not included still fails.
613615
`;
614616

615617
const vscodeQuickStartGuideContent = `# Visual Studio Code Quick Start
@@ -639,10 +641,10 @@ For the fastest local setup, start DocumentDB Local with Docker:
639641
640642
\`\`\`bash
641643
docker run -dt --name documentdb \\
642-
-p 10260:10260 \\
644+
-p 127.0.0.1:10260:10260 \\
643645
ghcr.io/documentdb/documentdb/documentdb-local:latest \\
644-
--username <YOUR_USERNAME> \\
645-
--password <YOUR_PASSWORD>
646+
--username '<YOUR_USERNAME>' \\
647+
--password '<YOUR_PASSWORD>'
646648
\`\`\`
647649
648650
If you prefer a host installation instead of Docker, use the [Linux Packages Quick Start](/docs/getting-started/packages) on a distribution in the current release matrix.
@@ -729,14 +731,19 @@ Connect to DocumentDB from Node.js using the official MongoDB driver.
729731
## Start DocumentDB Local
730732
731733
\`\`\`bash
734+
export DOCUMENTDB_USERNAME='<YOUR_USERNAME>'
735+
export DOCUMENTDB_PASSWORD='<YOUR_PASSWORD>'
736+
732737
docker run -dt --name documentdb \\
733-
-p 10260:10260 \\
738+
-p 127.0.0.1:10260:10260 \\
734739
ghcr.io/documentdb/documentdb/documentdb-local:latest \\
735-
--username <YOUR_USERNAME> \\
736-
--password <YOUR_PASSWORD>
740+
--username "\${DOCUMENTDB_USERNAME:?Set DOCUMENTDB_USERNAME}" \\
741+
--password "\${DOCUMENTDB_PASSWORD:?Set DOCUMENTDB_PASSWORD}"
737742
\`\`\`
738743
739-
> Replace \`<YOUR_USERNAME>\` and \`<YOUR_PASSWORD>\` with your own credentials.
744+
> Replace the placeholder values before running the command. The Node.js process below
745+
> reads the same two environment variables, so the credentials are passed as raw values
746+
> rather than embedded in a URI.
740747
>
741748
> DocumentDB Local uses a self-signed certificate by default, so the quickest local
742749
> Node.js connection uses \`tlsAllowInvalidCertificates=true\`.
@@ -757,12 +764,26 @@ Create an \`index.js\` file:
757764
\`\`\`javascript
758765
const { MongoClient } = require("mongodb");
759766
760-
const uri =
761-
"mongodb://<YOUR_USERNAME>:<YOUR_PASSWORD>@localhost:10260/" +
762-
"?authSource=admin&tls=true&tlsAllowInvalidCertificates=true&directConnection=true";
767+
const username = process.env.DOCUMENTDB_USERNAME;
768+
const password = process.env.DOCUMENTDB_PASSWORD;
769+
770+
if (!username || !password) {
771+
throw new Error(
772+
"Set DOCUMENTDB_USERNAME and DOCUMENTDB_PASSWORD before running this script"
773+
);
774+
}
775+
776+
const uri = "mongodb://localhost:10260/";
777+
const options = {
778+
auth: { username, password },
779+
authSource: "admin",
780+
tls: true,
781+
tlsAllowInvalidCertificates: true,
782+
directConnection: true
783+
};
763784
764785
async function main() {
765-
const client = new MongoClient(uri);
786+
const client = new MongoClient(uri, options);
766787
767788
try {
768789
await client.connect();
@@ -807,16 +828,21 @@ node index.js
807828
## Connect with a trusted local certificate instead
808829
809830
If you want certificate validation instead of \`tlsAllowInvalidCertificates=true\`,
810-
copy the generated certificate from the container and point the driver at it.
831+
copy the generated certificate from the container, then replace the \`options\` object
832+
above with the trusted-certificate version below.
811833
812834
\`\`\`bash
813835
docker cp documentdb:/home/documentdb/.local/state/documentdb-gateway/tls/cert.pem ~/documentdb-cert.pem
814836
\`\`\`
815837
816838
\`\`\`javascript
817-
const uri =
818-
"mongodb://<YOUR_USERNAME>:<YOUR_PASSWORD>@localhost:10260/" +
819-
"?authSource=admin&tls=true&tlsCAFile=/absolute/path/documentdb-cert.pem&directConnection=true";
839+
const options = {
840+
auth: { username, password },
841+
authSource: "admin",
842+
tls: true,
843+
tlsCAFile: "/absolute/path/documentdb-cert.pem",
844+
directConnection: true
845+
};
820846
\`\`\`
821847
822848
## Next steps
@@ -843,15 +869,22 @@ Use PyMongo to connect to DocumentDB, verify authentication and TLS, and run you
843869
For the fastest local setup, start DocumentDB Local with Docker:
844870
845871
\`\`\`bash
872+
export DOCUMENTDB_USERNAME='<YOUR_USERNAME>'
873+
export DOCUMENTDB_PASSWORD='<YOUR_PASSWORD>'
874+
846875
docker run -dt --name documentdb \\
847-
-p 10260:10260 \\
876+
-p 127.0.0.1:10260:10260 \\
848877
ghcr.io/documentdb/documentdb/documentdb-local:latest \\
849-
--username <YOUR_USERNAME> \\
850-
--password <YOUR_PASSWORD>
878+
--username "\${DOCUMENTDB_USERNAME:?Set DOCUMENTDB_USERNAME}" \\
879+
--password "\${DOCUMENTDB_PASSWORD:?Set DOCUMENTDB_PASSWORD}"
851880
\`\`\`
852881
853882
If you prefer a host installation instead of Docker, use the [Linux Packages Quick Start](/docs/getting-started/packages) on a distribution in the current release matrix.
854883
884+
> Replace the placeholder values before running the command. The Python process below
885+
> reads the same two environment variables, so the credentials are passed as raw values
886+
> rather than embedded in a URI.
887+
>
855888
> DocumentDB Local uses a self-signed certificate by default, so the quickest local
856889
> PyMongo connection uses \`tlsAllowInvalidCertificates=true\`.
857890
@@ -877,14 +910,26 @@ python -m pip install pymongo
877910
Create a \`quickstart.py\` file:
878911
879912
\`\`\`python
913+
import os
914+
880915
from pymongo import MongoClient
881916
882-
uri = (
883-
"mongodb://<YOUR_USERNAME>:<YOUR_PASSWORD>@localhost:10260/"
884-
"?tls=true&tlsAllowInvalidCertificates=true"
885-
)
917+
username = os.environ.get("DOCUMENTDB_USERNAME")
918+
password = os.environ.get("DOCUMENTDB_PASSWORD")
919+
920+
if not username or not password:
921+
raise RuntimeError(
922+
"Set DOCUMENTDB_USERNAME and DOCUMENTDB_PASSWORD before running this script"
923+
)
886924
887-
client = MongoClient(uri)
925+
client = MongoClient(
926+
"mongodb://localhost:10260/",
927+
username=username,
928+
password=password,
929+
authSource="admin",
930+
tls=True,
931+
tlsAllowInvalidCertificates=True,
932+
)
888933
889934
try:
890935
client.admin.command("ping")
@@ -934,15 +979,19 @@ for store in client["StoreData"]["stores"].find(
934979
935980
## Use a trusted local certificate instead
936981
937-
If you want certificate validation instead of \`tlsAllowInvalidCertificates=true\`, copy the generated certificate from the container and pass it to \`MongoClient\`.
982+
If you want certificate validation instead of \`tlsAllowInvalidCertificates=true\`, copy the generated certificate from the container, then replace the \`MongoClient\` call above with the trusted-certificate version below.
938983
939984
\`\`\`bash
940985
docker cp documentdb:/home/documentdb/.local/state/documentdb-gateway/tls/cert.pem ~/documentdb-cert.pem
941986
\`\`\`
942987
943988
\`\`\`python
944989
client = MongoClient(
945-
"mongodb://<YOUR_USERNAME>:<YOUR_PASSWORD>@localhost:10260/?tls=true",
990+
"mongodb://localhost:10260/",
991+
username=username,
992+
password=password,
993+
authSource="admin",
994+
tls=True,
946995
tlsCAFile="/absolute/path/documentdb-cert.pem",
947996
)
948997
\`\`\`
@@ -984,10 +1033,10 @@ For the fastest local setup, start DocumentDB Local with Docker:
9841033
9851034
\`\`\`bash
9861035
docker run -dt --name documentdb \\
987-
-p 10260:10260 \\
1036+
-p 127.0.0.1:10260:10260 \\
9881037
ghcr.io/documentdb/documentdb/documentdb-local:latest \\
989-
--username <YOUR_USERNAME> \\
990-
--password <YOUR_PASSWORD>
1038+
--username '<YOUR_USERNAME>' \\
1039+
--password '<YOUR_PASSWORD>'
9911040
\`\`\`
9921041
9931042
If you prefer a host installation instead of Docker, use the [Linux Packages Quick Start](/docs/getting-started/packages) on a distribution in the current release matrix.
@@ -1000,8 +1049,8 @@ If you prefer a host installation instead of Docker, use the [Linux Packages Qui
10001049
10011050
\`\`\`bash
10021051
mongosh localhost:10260 \\
1003-
-u <YOUR_USERNAME> \\
1004-
-p <YOUR_PASSWORD> \\
1052+
-u '<YOUR_USERNAME>' \\
1053+
-p '<YOUR_PASSWORD>' \\
10051054
--authenticationMechanism SCRAM-SHA-256 \\
10061055
--tls \\
10071056
--tlsAllowInvalidCertificates
@@ -1062,8 +1111,8 @@ the generated certificate from the container and pass it to \`mongosh\`.
10621111
docker cp documentdb:/home/documentdb/.local/state/documentdb-gateway/tls/cert.pem ~/documentdb-cert.pem
10631112
10641113
mongosh localhost:10260 \\
1065-
-u <YOUR_USERNAME> \\
1066-
-p <YOUR_PASSWORD> \\
1114+
-u '<YOUR_USERNAME>' \\
1115+
-p '<YOUR_PASSWORD>' \\
10671116
--authenticationMechanism SCRAM-SHA-256 \\
10681117
--tls \\
10691118
--tlsCAFile ~/documentdb-cert.pem
@@ -1118,9 +1167,9 @@ DocumentDB Local starts **empty**. Pass \`--init-data true\` to seed the \`Store
11181167
with the \`stores\` and \`ratings\` collections:
11191168
11201169
\`\`\`bash
1121-
docker run -dt -p 10260:10260 --name documentdb \\
1170+
docker run -dt -p 127.0.0.1:10260:10260 --name documentdb \\
11221171
ghcr.io/documentdb/documentdb/documentdb-local:latest \\
1123-
--username <YOUR_USERNAME> --password <YOUR_PASSWORD> --init-data true
1172+
--username '<YOUR_USERNAME>' --password '<YOUR_PASSWORD>' --init-data true
11241173
\`\`\`
11251174
11261175
Seeding happens once per data volume, on a fresh volume. Existing volumes are not migrated
@@ -1140,11 +1189,11 @@ The built-in sample dataset currently includes 41,505 store documents and 2 rati
11401189
11411190
\`\`\`bash
11421191
docker run -dt --name documentdb \\
1143-
-p 10260:10260 \\
1192+
-p 127.0.0.1:10260:10260 \\
11441193
-v /path/to/init/scripts:/init_doc_db.d \\
11451194
ghcr.io/documentdb/documentdb/documentdb-local:latest \\
1146-
--username <YOUR_USERNAME> \\
1147-
--password <YOUR_PASSWORD> \\
1195+
--username '<YOUR_USERNAME>' \\
1196+
--password '<YOUR_PASSWORD>' \\
11481197
--init-data-path /init_doc_db.d
11491198
\`\`\`
11501199
@@ -1183,8 +1232,8 @@ Before moving on to application code, confirm that DocumentDB is reachable and y
11831232
docker ps --filter "name=documentdb"
11841233
11851234
mongosh localhost:10260 \\
1186-
-u <YOUR_USERNAME> \\
1187-
-p <YOUR_PASSWORD> \\
1235+
-u '<YOUR_USERNAME>' \\
1236+
-p '<YOUR_PASSWORD>' \\
11881237
--authenticationMechanism SCRAM-SHA-256 \\
11891238
--tls \\
11901239
--tlsAllowInvalidCertificates

0 commit comments

Comments
 (0)