Skip to content

Commit 6ab01f4

Browse files
committed
add devcontainer
1 parent 1cd7465 commit 6ab01f4

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed

.devcontainer/Dockerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+

.devcontainer/devcontainer.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
]
20+
}
21+
}
22+
23+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
24+
// "forwardPorts": [3000, 27017],
25+
26+
// Use 'postCreateCommand' to run commands after the container is created.
27+
// "postCreateCommand": "yarn install",
28+
29+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
30+
// "remoteUser": "root"
31+
}

.devcontainer/docker-compose.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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:

.github/dependabot.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for more information:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://containers.dev/guide/dependabot
6+
7+
version: 2
8+
updates:
9+
- package-ecosystem: "devcontainers"
10+
directory: "/"
11+
schedule:
12+
interval: weekly

0 commit comments

Comments
 (0)