File tree 6 files changed +142
-33
lines changed 6 files changed +142
-33
lines changed Original file line number Diff line number Diff line change
1
+ FROM mcr.microsoft.com/devcontainers/javascript-node:1-22-bookworm
2
+
3
+ # Install MongoDB command line tools - though mongo-database-tools not available on arm64
4
+ ARG MONGO_TOOLS_VERSION=6.0
5
+ RUN . /etc/os-release \
6
+ && curl -sSL "https://www.mongodb.org/static/pgp/server-${MONGO_TOOLS_VERSION}.asc" | gpg --dearmor > /usr/share/keyrings/mongodb-archive-keyring.gpg \
7
+ && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] http://repo.mongodb.org/apt/debian ${VERSION_CODENAME}/mongodb-org/${MONGO_TOOLS_VERSION} main" | tee /etc/apt/sources.list.d/mongodb-org-${MONGO_TOOLS_VERSION}.list \
8
+ && apt-get update && export DEBIAN_FRONTEND=noninteractive \
9
+ && apt-get install -y mongodb-mongosh \
10
+ && if [ "$(dpkg --print-architecture)" = "amd64" ]; then apt-get install -y mongodb-database-tools; fi \
11
+ && apt-get clean -y && rm -rf /var/lib/apt/lists/*
12
+
13
+ # [Optional] Uncomment this section to install additional OS packages.
14
+ # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
15
+ # && apt-get -y install --no-install-recommends <your-package-list-here>
16
+
17
+ # [Optional] Uncomment if you want to install an additional version of node using nvm
18
+ # ARG EXTRA_NODE_VERSION=10
19
+ # RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
20
+
21
+ # [Optional] Uncomment if you want to install more global node modules
22
+ # RUN su node -c "npm install -g <your-package-list-here>"
23
+
24
+
25
+
Original file line number Diff line number Diff line change
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node-mongo
3
+ {
4
+ "name" : " Node.js & Mongo DB" ,
5
+ "dockerComposeFile" : " docker-compose.yml" ,
6
+ "service" : " app" ,
7
+ "workspaceFolder" : " /workspaces/${localWorkspaceFolderBasename}" ,
8
+
9
+ // Features to add to the dev container. More info: https://containers.dev/features.
10
+ // "features": {},
11
+
12
+ // Configure tool-specific properties.
13
+ "customizations" : {
14
+ // Configure properties specific to VS Code.
15
+ "vscode" : {
16
+ // Add the IDs of extensions you want installed when the container is created.
17
+ "extensions" : [
18
+ " mongodb.mongodb-vscode" ,
19
+ " streetsidesoftware.code-spell-checker"
20
+ ]
21
+ }
22
+ },
23
+ "features" : {
24
+ "ghcr.io/devcontainers-extra/features/jshint:2" : {}
25
+ },
26
+
27
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
28
+ // "forwardPorts": [3000, 27017],
29
+
30
+ // Use 'postCreateCommand' to run commands after the container is created.
31
+ "postCreateCommand" : " npm install"
32
+
33
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
34
+
35
+ }
Original file line number Diff line number Diff line change
1
+ version : ' 3.8'
2
+
3
+ services :
4
+ app :
5
+ build :
6
+ context : .
7
+ dockerfile : Dockerfile
8
+ volumes :
9
+ - ../..:/workspaces:cached
10
+
11
+ # Overrides default command so things don't shut down after the process ends.
12
+ command : sleep infinity
13
+
14
+ # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
15
+ network_mode : service:db
16
+
17
+ # Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
18
+ # (Adding the "ports" property to this file will not forward from a Codespace.)
19
+
20
+ db :
21
+ image : mongo:latest
22
+ restart : unless-stopped
23
+ volumes :
24
+ - mongodb-data:/data/db
25
+
26
+ # Uncomment to change startup options
27
+ # environment:
28
+ # MONGO_INITDB_ROOT_USERNAME: root
29
+ # MONGO_INITDB_ROOT_PASSWORD: example
30
+ # MONGO_INITDB_DATABASE: your-database-here
31
+
32
+ # Add "forwardPorts": ["27017"] to **devcontainer.json** to forward MongoDB locally.
33
+ # (Adding the "ports" property to this file will not forward from a Codespace.)
34
+
35
+ volumes :
36
+ mongodb-data:
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ const mongoose = require("mongoose");
27
27
mongoose . set ( "strictQuery" , false ) ;
28
28
29
29
const dev_db_url =
30
- "mongodb+srv ://cooluser:coolpassword@cluster0.cojoign.mongodb.net /local_library?retryWrites=true&w=majority&appName=Cluster0" ;
30
+ "mongodb://localhost:27017 /local_library"
31
31
const mongoDB = process . env . MONGODB_URI || dev_db_url ;
32
32
33
33
main ( ) . catch ( ( err ) => console . log ( err ) ) ;
Original file line number Diff line number Diff line change 11
11
"serverstart" : " DEBUG=express-locallibrary-tutorial:* npm run devstart"
12
12
},
13
13
"dependencies" : {
14
+ "async" : " ^3.2.6" ,
14
15
"compression" : " ^1.7.4" ,
15
16
"cookie-parser" : " ^1.4.6" ,
16
17
"debug" : " ^4.3.5" ,
21
22
"helmet" : " ^7.1.0" ,
22
23
"http-errors" : " ^2.0.0" ,
23
24
"luxon" : " ^3.4.4" ,
24
- "mongoose" : " ^8.9.5 " ,
25
+ "mongoose" : " ^8.15.0 " ,
25
26
"morgan" : " ^1.10.0" ,
26
27
"pug" : " ^3.0.3"
27
28
},
You can’t perform that action at this time.
0 commit comments